Looping


In computer programming, a loop is a sequence of commands or statements that are repeated many times.

Looping statements in C language are as under:

  1. for statement
  2. while statement
  3. do…while statement

Let us learn C programming Looping concept by executing following programs.

1. C programs based on for statement:




2. C programs based on while statement:
3. C programs based on do…while statement:

Sample Programs:



#include<stdio.h>
int main()
{
  int i;
  for(i=1; i<=10; i++)
  {
     printf("%d ", i);
  }

  return 0;
}
/*Output
1 2 3 4 5 6 7 8 9 10
*/



* * * * *

1 comment: