Programming-Idioms

History of Idiom 2 > diff from v94 to v95

Edit summary for version 95 :
[C] C99 allows declaring variables inside for statement

Version 94

2019-09-27, 16:41:04

Version 95

2019-09-27, 19:08:35

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Code
int i;
for(i=0;i<10;i++)
  printf("Hello\n");
Code
for (int i = 0; i < 10; i++) printf("Hello\n");
Comments bubble
Note the necessary newline (\n), not to print every time on the same line
Comments bubble
Note the necessary newline (\n), not to print every time on the same line