What would happen when we compile and run this program?
(A) No compile error and it will print GeeksQuiz 10 times because goto label LOOP wouldn’t come in effect.
(B) No compile error and it’ll print GeeksQuiz only once because goto label LOOP would come in picture only after entering for loop.
(C) Compile Error because any goto label isn’t allowed in for loop in C.
(D) No compile error but behaviour of the program would depend on C compiler due to nondeterministic behaviour of goto statement.
(E) No compile error and it will not print anything.
Explanation: goto statement can be used inside a function and its label can point to anywhere in the same function. Here, for loop expressions i.e. i = 0 and i < 10 and i++ wouldn’t be executed at all. Because goto would make the program jump directly inside the for loop. And from there, it’ll execute break statement which would exit the loop. So effectively nothing would be printed.
Quiz of this Question
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- C | C Quiz - 113 | Question 1
- C Quiz - 112 | Question 1
- C Quiz - 112 | Question 2
- C Quiz - 107 | Question 2
- C Quiz - 110 | Question 3
- C Quiz - 106 | Question 1
- C Quiz - 106 | Question 2
- C Quiz - 106 | Question 3
- C Quiz - 106 | Question 4
- C Quiz - 106 | Question 5
- C Quiz - 107 | Question 1
- C Quiz - 111 | Question 3
- C Quiz - 107 | Question 3
- C Quiz - 112 | Question 3
- C Quiz - 109 | Question 1