+ 7
How exactly does the continue statement work?
Can anyone explain with an example?
4 Antworten
+ 9
Thank you for the answer, Luis Sepúlveda!
+ 6
Thanks for the answer, Omkar{status:exams;} !
+ 4
The continue statement in C is used in loops like while, do while, and for loops..
Whenever a continue statement is encountered in code it passes control of program to next iteration of loop without executing other statements in loop.. as Luis Sepúlveda already mentioned it can be used to print even or odd numbers ...the code may can help u understand better... Happy learning 😊
https://code.sololearn.com/c9nv1F6LPxs1/?ref=app
+ 1
The continue statement in a loop helps you skip over the iteration you are currently on and on to the next one.
The most given example is when you want to print only even, or only odd numbers:
#For numbers between 0 & 11
For x in range (12):
# If x is odd
if x%2==1:
continue
print(x)
#Output: 0, 2, 4, 6, 8, 10
I wish you success!