for (initial; condition; increment) { statement; }
for (i = 0; i < 10; i++) printf("%d\n", i);There is only 1 statement inside of the loop, so you can omit { }.
for (i = 0; i < 10; i++) { squared = i * i; printf("%d\n", squared); }
Frequently, you need to have multiple statements within a loop.
A block is a group of 2 or more statements enclosed in braces.
See the source code for the immigration-emigration process.
for (i = 5; i > 0; i--) { for (j = 0; j < 3; j++) { printf("i = %d, j = %d\n", i, j); } printf("End of the outside loop\n"); }
for(i=0, j=10; i<3; i++, j--) printf("%d\n", i+j);
i = 0; for( ; i<3; printf("\n")) { printf("%d", i); i++; }
for(i=0; i<3; j++) printf("%d\n", i);
for(i=0; i<10; i--) printf("%d\n", i);
for(i=0; i<10; i--); printf("%d\n", i);