For loop

Written By -

 

For loop

 

A loop help us to repeat a statement or group of statements until it satisfies the particular given condition.

For Loop: For loop is the most popular loop and is widely used loop in computer programming.

  • For for loop we need to specify three things:
  • 1. First we need to setup initial value for the loop counter.
  • 2. Then, we need to check that the value of loop counter reached the number of required repetitions.
  • 3. Last one will increment the value of loop counter .

 

The syntax of for loop is as follows:

                   
for (init; condition; increment)
  {
      Statement(s);
  }

Example :

                   
 #include &ltstdio.h>
int main()
{
  
  for(i=1; i<5; i++)
  {
  printf(“Value:%d/n”,i)

  return 0;
}

Output :

Value: 1 
Value: 2
Value: 3 
Value: 4

Report Error/ Suggestion

Related Posts:

[yuzo_views]











CopyRight © 2019

CopyRight © 2019