Logo

Programming-Idioms

History of Idiom 2 > diff from v104 to v105

Edit summary for version 105 by :
Restored version 101

Version 104

2019-11-23, 21:06:13

Version 105

2019-11-23, 23:00:10

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 < 100; i++)
{
  System.Console.WriteLine("Hello");
}
Code
for (int i = 0; i < 10; i++)
{
  System.Console.WriteLine("Hello");
}
Code
#include <stdio.h>
int main()
{
  int i;
  for (i = 0; i < 10; i++)
  {
    printf(" Hello Holberton\n");
  }
  return 0;
}

}
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