C Output Questions

Read a short C program and predict what it prints. Get one wrong and watch the program run to the exact step that decides it.

  • 20 questions on decisions, loops, arrays and strings
  • Wrong answers are the mistakes beginners really make, each explained
  • Watch why: the dry run plays up to the deciding step
  • Every question links to the full program, flowchart and dry run

Frequently asked questions

What does a C loop for (i = 1; i <= 5; i++) sum = sum + i; print when sum starts at 0?

Sum = 15. The loop runs for i = 1 to 5 because the condition is i <= 5, so it adds 1 + 2 + 3 + 4 + 5.

What is the factorial of 5 printed by a C loop that starts fact at 1?

120. The loop multiplies 1 × 2 × 3 × 4 × 5. A common wrong answer is 24, which skips the last round.

What does printf("%.2f", 30.0) print in C?

30.00. %.2f always prints two decimal places.

Does a C string-length loop count the \0 character?

No. A loop like while (word[count] != '\0') count++; stops at the closing \0, so "hello" has length 5.

Is this practice free?

Yes, every question is free and needs no sign-up.

Try AI Flowchart free →