2.2 Control Sturcture
2.2 Control Sturcture
• Format:
if (condition) Example:
then-part
if (total_mark is greater than 50)
else print “Pass”
else
else-part
print “Fail!”
end_if end_if
set cumulative_sum to 0
set current_number to 1
while (current_number is less or equal to 10)
add the cumulative_sum to current_number
add 1 to current_number
end_while
print the value of cumulative sum
• Note that in this algorithm, we are using both the sequence and repetition
control structure