C for Loop statement

For Loop statement is used to do some operation for number of times until some condition is true.


For example, if you want print 1 to 100 numbers, then for loop can be used.

Syntax of for loop statement is as below.

for(<initial_statement>; <condition_expression>; <increment_statement>) {
        <body_of_for_loop>
}

<initial_statement> : is generally where you initialize variables. Statement written in this part will be executed only once. i.e Before entering into for..loop.
<condition_expression> : body of for loop will be executed till this given <condition_expression> is true.
<increment_statement> : statement written in this part will be executed after each iteration of for loop. This is where you would increment/decrement variables.
<body_of_for_loop> : statement(s) written in this part will be executed during each iteration of for loop. 

Flow chart of for loop statement:

Flow Chart of for...loop

 

Example of for...loop statement:
In this example, we have printed 1 to 100 numbers using for loop.