+ 3

The innermost

In the "loop" lessons it was taught that "continue" skips the innermost loop. here is my problem... for(int x=0;x<10;x++) { if(x==5) { continue; } console.writeline(x); } the output is: 0 1 2 3 4 6 7 8 9 the question is that isn't "if" a loop? and doesn't "continue" skips the innermost loop? so why skipping "console.writeline(x)" when its not in the "if" loop??? forgive me if my question seems stupid for those of you who are professional 🙏 I'm just a beginner.

18th Mar 2017, 2:51 PM
Amir Hossein Karimi
Amir Hossein Karimi - avatar
4 Antworten
+ 19
If-statements are conditional statements, not loops.
18th Mar 2017, 3:07 PM
Hatsy Rei
Hatsy Rei - avatar
+ 15
The continue statement tells the program to go to the top of the loop statement, and run again. When x is 5, continue statement was met and program went to the top of the loop, x gets incremented to 6 and runs the rest of the loop.
18th Mar 2017, 3:02 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
tnx for the guidance... but I was looking back at the lessons and realised something... Can we say the "if" is an "statement" not a "loop"?
18th Mar 2017, 3:06 PM
Amir Hossein Karimi
Amir Hossein Karimi - avatar
+ 3
yeahhh that was my problem for misunderstanding them. thank u so much 😄 now it makes sense.
18th Mar 2017, 3:09 PM
Amir Hossein Karimi
Amir Hossein Karimi - avatar