5 votes 5 votes What is the output of the following C code? #include <stdio.h> int main() { int index; for(index=1; index<=5; index++) { printf("%d", index); if (index==3) continue; } } 1245 12345 12245 12354 Programming in C isro2011 programming-in-c loop + – go_editor asked Jun 23, 2016 edited Dec 9, 2022 by Lakshman Bhaiya go_editor 5.5k views answer comment Share Follow See all 10 Comments See all 10 10 Comments reply Show 7 previous comments AkshayNagarwal commented May 26, 2023 reply Follow Share To define if statement's body. Boundaries needed to define your home size. 0 votes 0 votes AkshayNagarwal commented May 26, 2023 reply Follow Share I know you thinking(algorithmic) the answer will 1245 for skipping 3 in print. 0 votes 0 votes Arjun commented May 26, 2023 reply Follow Share Not sure what you are saying. But the given code is a syntactically valid C code. 0 votes 0 votes Please log in or register to add a comment.
Best answer 10 votes 10 votes B)12345 Here continue is last line . So,it will not skip any number srestha answered Jun 23, 2016 selected Jun 23, 2016 by Arjun srestha comment Share Follow See all 4 Comments See all 4 4 Comments reply Amit Sharma commented Jul 12, 2016 reply Follow Share What does this line mean Here continue is last line . So,it will not skip any number . if continue would be a middle line would that changed the answer ? please comment . 1 votes 1 votes srestha commented Jul 13, 2016 reply Follow Share @Amit The continue skips the statements after it. And continues with next iteration. 1 votes 1 votes Sayan Bose commented May 1, 2018 reply Follow Share @srestha , I guess you meant to say since continue statement is in the last line , it would not have to skip any lines/statements after it 1 votes 1 votes srestha commented May 1, 2018 reply Follow Share yes.. 0 votes 0 votes Please log in or register to add a comment.
6 votes 6 votes ans is (b) The continue statement in C programming works somewhat like thebreak statement. Instead of forcing termination, it forces the next iteration of the loop to take place, skipping any code in between. kvkumar answered Jun 26, 2016 edited Jul 12, 2016 by kvkumar kvkumar comment Share Follow See all 2 Comments See all 2 2 Comments reply Amit Sharma commented Jul 12, 2016 reply Follow Share what does this statement has to do with the answer of this question ? your statement does not explain that the answer of this question is 12345. 1 votes 1 votes kvkumar commented Jul 12, 2016 reply Follow Share i am saying about continue stmt in this ex whenever a=15 the loop is skiping #include <stdio.h> int main () { int a = 10; /* do loop execution */ do { if( a == 15) { /* skip the iteration */ a = a + 1; continue; } printf("value of a: %d\n", a); a++; } while( a < 20 ); return 0; } output is value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 16 value of a: 17 value of a: 18 value of a: 19 suppose if we replace above code the output is 1245 #include <stdio.h> int main() { int index; for(index=1; index<=5; index++) { if (index==3) continue; printf("%d", index); } } in this case ans is 1245 1 votes 1 votes Please log in or register to add a comment.