/*
/// For loop
A for loop is a repetition control structure which allows us to
write a loop that is executed a specific number of times.
The loop enables us to perform n number of steps together in one line.
Syntax:
for (initialization expression; test expression; update expression)
{
// body of the loop
// statements we want to execute
}
In for loop, a loop variable is used to control the loop.
First initialize this loop variable to some value,
then check whether this variable is less than or
greater than counter value. If statement is true,
then loop body is executed and loop variable gets updated .
Steps are repeated till exit condition comes.
1.Initialization Expression: In this expression we have to
initialize the loop counter to some value. for example: int i=1;
2.Test Expression: In this expression we have to test the condition.
If the condition evaluates to true then we will execute the body of
loop and go to update expression otherwise we will exit from the for loop.
For example: i <= 10;
3.Update Expression: After executing loop body this expression
increments/decrements the loop variable by some value. for example: i++;
*/
#include<stdio.h>
int main()
{
int i=0;
for ( i = 0; i <=10; i++)
{
printf("hello world\n");
}
return 0;
}
Comments
Post a Comment