ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
int i, c = 0;
for (i = 0; i < 6; i++)
    if (i % 2 == 0 || ++c > 1)
        c += 10;
printf("%d %d", i, c);
  1. A. 6 60
  2. B. 6 33
  3. C. 6 63
  4. D. 5 63

Correct answer: C. 6 63

|| evaluates its right side only when the left side is false. For even i the left is true, so ++c is skipped and c += 10 runs. For odd i, ++c runs and, since c is already above 1, the condition is true and c += 10 also runs. Even i: 3 × 10; odd i: 3 × 11 → 30 + 33 = 63, and the loop ends with i = 6. 60 forgets the ++c increments.

More C Programming questions

Exams that ask this topic