Logo

Programming-Idioms

History of Idiom 2 > diff from v95 to v96

Edit summary for version 96 by phrank:
[C] Add curly braces to conform other examples

Version 95

2019-09-27, 19:08:35

Version 96

2019-09-27, 19:09:57

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
for (int 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