Sample Program on Loops

Looping statements are used to execute a block code zero or more times. Looping statements are also known as iterative statements. C programming language supports the following looping statements:

  1. while
  2. do-while
  3. for

while - loop has test the condition first if it is true than executes the body until condition becomes false.

Syntax:
while(condition){
    statement(s);
}
Example:
#include<stdio.h>

int main() {
  int i = 1;
 
  while(i<=5){
    printf("Hello Govardhan\n");
    i++;
  }
  return 0;
}
Output:
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Hello Govardhan
Try Yourself