Loops are used to repeatedly execute a block of code. Some times in ‘C’ we don’t want to execute the same instruction which is already executed again & again.
In such scenario, the control has to be taken back to previous statements which are already executed. Taking control back to previous statement is known as looping.
C provides us three different looping structures:-
- for loop.
- while loop.
- do while loop.
- Nested loops
- For Loop
- Flow chart of nested if else
The for loop statement is the first& perhaps the most commonly is used looping statement in C.
The general form is:
for (initiazation_expression; test condition; increment/decrement operation)
Ex: for(int i=0;i<10;i++)