← Quiz: C Control Flow: all 10 questions
Quiz: C Control Flow · Question 2 of 10
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
int i;
for (i = 0; i < 5; i++);
printf("%d", i);
return 0;
}
- A.01234
- B.4
- C.5
- D.0
Answer & explanation
Correct answer: 5
The semicolon ends the loop body, so the loop just counts to 5, then printf runs once.
Can you get the rest right without peeking?
Take the timed Quiz: C Control Flow quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →