What's the output of this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What's the output of this code

#include<stdio.h> int main(){ int x; for(x=-1; x<=10; x++){ if(x < 5) continue; else break; printf("c programming");} return 0;}

4th Feb 2022, 8:45 AM
saurav
saurav - avatar
3 Answers
+ 5
Oh. Sry i did not checked code clearly.. but mention question clearly.. #include<stdio.h> int main() { int x; for(x=-1; x<=10; x++){ if(x < 5) continue; //causes loop stop current iteration ,go with next iteration else break; //causes loop break printf("c programming"); //never touched } return 0; } /* initially x= -1, so x<=10 and next x<5 is true, so continue with next iteration x++ => x=0 x<5 is true, so continue with next iteration x++ => x=1 x<5 is true, so continue with next iteration x++ => x=2 x<5 is true, so continue with next iteration x++ => x=3 x<5 is true, so continue with next iteration x++ => x=4 x<5 is true, so continue with next iteration x++ => x=5 x<5 is false, so goes to else and break cause to break the loop. so loop gets terminated here Till now, and outside of loop, no output statements executed so no output.... edit: saurav do you trying to get any output? hope it clears..
4th Feb 2022, 9:42 AM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 it's showing no output ! Btw basically I want to know how output come I mean logic behind 🤔it
4th Feb 2022, 9:00 AM
saurav
saurav - avatar
0
Check in playground.... edit:
4th Feb 2022, 8:58 AM
Jayakrishna 🇮🇳