Need Help. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Need Help.

Why this code print "Hello World" 5 times? Code: https://code.sololearn.com/c0jDmo4gtf8W/?ref=app

10th Apr 2018, 6:43 AM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
2 Answers
+ 10
The loop skips the iteration when the value of i == 3 (due to the continue statement) and works for the rest normally. The control flow - × when i==1 => prints Hello world × when i==2 => prints Hello world × when i==3 => skips this iteration × when i==4 => prints Hello world × when i==5 => prints Hello world × when i==6 => prints Hello world Therefore Hello World is printed five times. P.S. - Learn more about the break and continue statements in C - https://www.sololearn.com/learn/2388/?ref=app
10th Apr 2018, 7:40 AM
Nikhil
Nikhil - avatar
+ 4
if(i==3)continue; When the value of the i is 3, the printf isn't excuted.
10th Apr 2018, 7:32 AM
Disvolviĝo;
Disvolviĝo; - avatar