0% found this document useful (0 votes)
35 views2 pages

Summary Different Statements

The document describes different types of control structures in programming including selection (if/else), repetition (while, do/while, for), and switch. It provides the pseudo code, flow diagram, and C code representations for each control structure type. Selection structures include if and if/else for conditional execution. Repetition structures include while, do/while, and for for repeated execution of code. Switch allows evaluating a value against multiple cases.

Uploaded by

Babette Frey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Summary Different Statements

The document describes different types of control structures in programming including selection (if/else), repetition (while, do/while, for), and switch. It provides the pseudo code, flow diagram, and C code representations for each control structure type. Selection structures include if and if/else for conditional execution. Repetition structures include while, do/while, and for for repeated execution of code. Switch allows evaluating a value against multiple cases.

Uploaded by

Babette Frey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Control Pseudo code Flow diagram C code

if if condition is met then


if (condition)
selection perform statements true statement;

OR

if (condition)
{
true statements;
}
(

if ... else if condition is met then


if (condition)
selection perform statements true statements;
otherwise else
perform statements false statements;

OR

if (condition)
{
true statements;
}
else
{
false statements;
}

while while condition is met


while (condition)
repetition repeatedly repeated statement;
perform actions
OR

while (condition)
{
repeated statements;
}

CP143 Control structures - Group 4. Thinus


do while repeatedly
do
repetition perform actions repeated statement;
while condition is met while (condition);

OR

do
{
repeated statements;
}
while (condition);

for initialize
repetition evaluate condition for(initialize;
if condition repeatedly condition;
perform actions increment)
perform increment statement;
re-evaluate condition OR

for(initialize;
condition;
increment)
{
statements;
}

switch for each case, from the


switch ( val ){
selection first case, evaluate a case 1 :
value against cases. actions(s);
if the value equal to case break;
perform actions case 2 :
actions(s);
if "break", break;
exit switch default:
else actions(s);
assume all remaining }
cases true
else evaluate next case.
if "default" reached Note:
1. If the break is
perform default actions omitted in a case, the
exit switch subsequent cases will
all evaluate and do so
as if true.
2. All the cases need
to be constant values.
3. default is optional

CP143 Control structures - Group 4. Thinus

You might also like