Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 9

FLOW OF CONTROL

By-Utkarsh Srivastava
Class- XI-

STATEMENTS
Null/Empty statementSyntax- ;
Use-demand by syntax but no use in logic
Compound statement(Block)Syntax- {
statement1;
statement2;
..
..
}

STATEMENTS FLOW CONTROL


Types of execution of statements in a program1.Sequence construct-Execution of statements in sequentially

2.Selection construct-Execution of statements on a condition-test

3. Iteration-repeated execution of statements on a condition-check

SELECTION/CONDITIONAL/DECISION
STATEMENTS1. If statements
Syntaxif(expression)
statement;
a) If-else statement
Syntaxif(expression)
statement1;
else
statement2;

b) The dangling elseSyntax- if(expr 1)


if(expr 2)
statement1;
else
statement2;
else
statement3;
c) The if-else-if ladderSyntax- if (expression 1) statement 1;
else
if (expression 2) statement 2;
else
if (expression 3) statement 3;

else statement 4;

THE SWITCH STATEMENT


Syntaxswitch (expression)
{
case constant1 :
statement sequence 1;
break;
case constant2:
statement sequence2;
break;
case constant3:
statement sequence3;
break;
.
.
.
case constant n-1 :statement sequence n-1;
break;
[default :
statement sequence n];

ITERATION STATEMENTS
1. For loop- entry controlled loop
Syntaxfor(initialization expression(s); test-expression; update expression(s))
body of the loop ;
2. The while loop- entry controlled loop
Syntaxwhile (expression)
loop body
3. The do-while loop- exit controlled loop
Syntaxdo {
statement ;
}
while (test-expression) ;

JUMP STATEMENTS
1.

The goto statement

Syntax-

goto label;

.
.
.
label :
2.

The break Statement

3. The continue statement

4. The exit() function- Breaks out of a program

You might also like