Control Structures
Control Structures
CONTROL STRUCTURE
Iteration statement
Jumps in statement
SELECTION STATEMENT
Selection statement is also called as Decision making
statements because it provides the decision making
capabilities to the statements.
true
It allows the computer to evaluate the expression
first and then depending on whether the value of the
expression is ‘true’ or ‘false’, it transfers the control
to particular statement.
IF STATEMENT
The if-statement may be implemented in different
forms depending on the complexity of condition
to be tested.
1. Simple if Statement
2. If…else Statement
3. Nested if...else Statement
4. else if ladder
SIMPLE IF STATEMENT
The general form of a simple if statement is…
}
THE SWITCH STATEMENT
Often a break statement is used as the last statement in
each case's statement list
A break statement causes control to transfer to the end of
the switch statement
If a break statement is not used, the flow of control will
continue into the next case
Sometimes this may be appropriate, but often we want to
execute only the statements associated with one case
THE SWITCH STATEMENT
An example of a switch statement:
switch (option)
{
case 'A':
aCount++;
break;
case 'B':
bCount++;
break;
case 'C':
cCount++;
break;
}
THE SWITCH STATEMENT
A switch statement can have an optional default case