For loop in c

For loop is an Entry control loop used widely for iteration purpose in c programming, first let’s observe syntax of For loop.


for(initiation ;test condition ;update)

there are 3 parts separated by a semicolon(;), the first part is called initiation, in this initiation, the index variable is initialized, means the first value of the variable is declared here. the second part is test condition, here the condition of the whole loop is represented here if the condition fails the loop stops (or) for loop executes the statements put in braces after for until the test variable reaches the end value, the condition expression is made with relational operators along with logical operators .Third one is step for the next upcoming value, the step should be in the arithmetic expression. every time when test condition is true code inside the braces is executed with the updated step condition until the test condition reaches end value


for loop in c
int main()
int i,sum;
sum += i;



here, in the above example first the initialization takes place, the index value of the variable i is 1 .next the condition is the i should be lesser than or equal to ten. the third one is the step where, for every loop ,the value i increases one time .after the test condition reaches end value 10 the loop stops by printing the total as output