Question 74

What is the output of the following C program? # include

What is the output of the following C program? # include int main ( ) { int index; for (index = 1; index < = 5; index ++) { printf ("%d", index); if (index = = 3) continue; } }
  1. A1245
  2. B12345
  3. C12245
  4. D12354
Show answerHide answer

Correct answer: (B) 12345

Explanation

printf runs before the if statement, so continue only skips the (empty) rest of the loop body. Every value from 1 to 5 is printed: 12345.

From DSSSB TGT Computer Science Practice Set 1

This is question 74 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.