For Loop: allow us to efficiently write a loop that needs to be executed  specific number of times.
Syntax:
for(init statement; test expression; increment)
{
       code(s) to be executed; 
}
- The init statement allow us to
initialize any loop control
variable. This statement is executed
once at the beginning of loop.
 
- Next, the test expression is
evaluated. If the condition is true,
the body of the loop is executed
else the control flow jumps to the
next statement out of the loop.
 
- The increment statement can be left
blank as long as the semicolon
appers after the condition.
 
For loop example:
# include<stdio.h>
int main () 
{
   int x;
   for( x = 5; x < 10; x++ )
    {
        printf("value of x is: %d\n", x);
       }
   return 0;
}
Output:
value of x is: 5
value of x is: 6
value of x is: 7
value of x is: 8
value of x is: 9
                       
                    
0 Comment(s)