Presented by:
Anil pokhrel
1
 Flow of control
 Statement
 Selection /decision
 Iteration/loop
 Jump statements
2
 The flow of control jumps from one part of
the program to another, depending on
calculations performed in the program
 Program statements that cause such jumps
are called control statements. There are
two major categories: loops and decisions
3
4
 Statements are the instructions given to
the computer to perform any kind of
action , be it data movements, be it
making decisions or be it repeating actions.
 Statements are the smallest executing unit
of a C++ program.
5
 A compound statement in C++ is a sequence
of statements enclosed by a pair of
branches { }.
{
statements 1 ;
statements 2 ;
: }
represents a compound statement
6
 The selection construct means the execution
of statements depending upon a condition
evaluates true, a set of statements is
followed.
7
8
 Also known as either or. This statement is
used to select one statement and ignore the
other statements.
if(condition)
s1;
else
s2;
when the condition is true statement
s1 is executed. If the condition is false s2 is
executed. Thus one of the statements, either s1
or s2 is always executed
9
 It is a multi branch statement which can be used
to select and execute one of the available
statements.
switch(value)
{
case 1: statement 1;
break;
case 2: statement 2;
break;
case n: statement n;
break;
default: statement d;
}
10
 Loops cause a section of your program to be
repeated a certain number of times.
 When the condition becomes false, the loop
ends and control passes to the statements
following the loop
11
 for
Natural "counting" loop
 do-while
Least flexible Always executes loop body
at least on
 while
Most flexible No “restrictions
12
 It is a repeated structure which can repeat a
statement as long as the given condition is
satisfied.
for(statement1; condition; statement2)
statement3;
13
While loop
while(condition)
statement1;
Do while loop
do
{
statement1;
}
while(condition);
14
 The types of jump statement are:
1)Break
2)Continue
3)Goto
4)Exit
5)Return
15
1)cpluspluslearner.blogspot.com/2012/05/cont
rol-statements-in-c.htm
2)https://www.cs.bu.edu/teaching/cs111/spri
ng-2000/control-flow/
16
17
18

Control statement

  • 1.
  • 2.
     Flow ofcontrol  Statement  Selection /decision  Iteration/loop  Jump statements 2
  • 3.
     The flowof control jumps from one part of the program to another, depending on calculations performed in the program  Program statements that cause such jumps are called control statements. There are two major categories: loops and decisions 3
  • 4.
  • 5.
     Statements arethe instructions given to the computer to perform any kind of action , be it data movements, be it making decisions or be it repeating actions.  Statements are the smallest executing unit of a C++ program. 5
  • 6.
     A compoundstatement in C++ is a sequence of statements enclosed by a pair of branches { }. { statements 1 ; statements 2 ; : } represents a compound statement 6
  • 7.
     The selectionconstruct means the execution of statements depending upon a condition evaluates true, a set of statements is followed. 7
  • 8.
  • 9.
     Also knownas either or. This statement is used to select one statement and ignore the other statements. if(condition) s1; else s2; when the condition is true statement s1 is executed. If the condition is false s2 is executed. Thus one of the statements, either s1 or s2 is always executed 9
  • 10.
     It isa multi branch statement which can be used to select and execute one of the available statements. switch(value) { case 1: statement 1; break; case 2: statement 2; break; case n: statement n; break; default: statement d; } 10
  • 11.
     Loops causea section of your program to be repeated a certain number of times.  When the condition becomes false, the loop ends and control passes to the statements following the loop 11
  • 12.
     for Natural "counting"loop  do-while Least flexible Always executes loop body at least on  while Most flexible No “restrictions 12
  • 13.
     It isa repeated structure which can repeat a statement as long as the given condition is satisfied. for(statement1; condition; statement2) statement3; 13
  • 14.
    While loop while(condition) statement1; Do whileloop do { statement1; } while(condition); 14
  • 15.
     The typesof jump statement are: 1)Break 2)Continue 3)Goto 4)Exit 5)Return 15
  • 16.
  • 17.
  • 18.