semicolong after for() loop stackoverflow
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++)
printf("%d ", i);
return 0;
}
Explanation:
The
main
function is the entry point of the program.Inside the
main
function, afor
loop is used. The loop initializes the variablei
to 0, checks ifi
is less than 5, and incrementsi
by 1 after each iteration.The loop body contains a
printf
statement that prints the current value ofi
followed by a space.The loop will execute five times (for
i
values 0 to 4), printing the values 0, 1, 2, 3, and 4.After the
for
loop, themain
function returns 0, indicating successful execution of the program.