C Programming Examples Tutorial Index

C Loop Programs


In this tutorial, a basic C program is demonstrated to print Hello World several times as the output on the screen. The primary aim of this C program is to explain to beginners how the printf() function works inside the loop.

Example C Program:
//C program to print Hello World several times as output on the screen.
#include<stdio.h>

void main ()
{
  int num, i;
  printf ("Enter the number of times the string should be printed: ");
  scanf ("%d", &num);
  for (i = 1; i <= num; i++)
    {
      printf ("Hello World\n");
    }
}
Program Output:
Enter the number of times the string should be printed: 4
Hello World
Hello World
Hello World
Hello World