Page 220 - Computer Science Class 11 Without Functions
P. 220
9.5.2 continue Statement
Continue statement is also a jump statement, just like the break statement. When a continue statement is
encountered, the remaining statement(s) in the loop is skipped and the control jumps to the beginning of the loop for
the next iteration. The flowchart in fig 9.6 illustrates the working of continue statement.
Syntax:
continue
False Test
condition
True
Enter Loop
Continue
Exit Loop
Fig 9.6: Working of continue statement
As the control moves to the next iteration, firstly, the loop variable is updated with the next value in the sequence
or range. Thereafter, if the updated loop variable is within the range/ sequence or if the test condition is True, the
execution of the statements in the body of the loop takes place. Consider the examples given below, that explain the
working of continue statement in for loop and while loop.
for x in range(1, 5): num = 5
if x == 3: while num <= 10:
continue if num % 4 == 0:
else: num = num + 1
print(x) continue
print('Over') else:
print(num * num)
num = num + 1
print("Done")
Output: Output:
1 25
2 36
4 49
Over 81
100
Done
break and continue statements are usually part of the body of the if statement.
218 Touchpad Computer Science-XI

