What is the output of the following C program?
#include <stdio.h>
int main(void) {
int i;
for (i = 0; i < 5; i++);
printf("%d\n", i);
return 0;
}
The semicolon right after the header is the loop body – an empty statement. The loop counts i up to 5, and only then does printf run, once. Compilers warn about this classic slip.