Programs · Program 6-15
Q.Program 6-15: Program to demonstrate the use of continue statement.
Yanam CbseNCERTSubjective· 2mImportance★★★★★est
49% · 19/39 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →continue abandons just the current pass of a loop and moves on to the next value — here every even number is skipped, so the loop prints the odd numbers 1, 3, 5, 7, 9 and still runs to completion.
The idea. Where break ends the whole loop, continue ends only the current iteration: control jumps straight back to the loop header for the next value, skipping whatever statements remain in the body. It is the tool for "ignore this case and carry on".
# Program 6-15: demonstrate the use of the continue statement
for num in range(1, 11):
if num % 2 == 0:
continue # skip the rest of the body for even numbers
print(num)
print("End of loop")
Expected output
1
3
5
7
9
End of loop
How it works
num= 1: odd → theifis False →print(1).num= 2: even →continueexecutes →print(num)is skipped, and the loop immediately proceeds withnum= 3.- The same pattern repeats up to 10, so exactly the odd values are printed.
- Unlike
break, the loop is never cut short: all ten values ofnumare examined, and the final message after the loop prints once.
break vs continue at a glance
| Statement | Effect on current pass | Effect on remaining passes | …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.