Looping Statements in C / Iterative Statements in C:
‘A loop’ is a part of code of a program which is executed repeatedly.
A loop is used using condition. The repetition is done until condition becomes true.
A loop declaration and execution can be done in following ways.
– Check condition to start a loop
– Initialize loop with declaring a variable.
– Executing statements inside loop.
– Increment or decrements of value of a variable.
TYPES OF LOOPING STATEMENTS IN C:
Basically, the types of looping statements depends on the condition checking mode. Condition checking can be made in two ways as : Before loop and after loop. So, there are 2(two) types of looping statements.
– Entry controlled loop
– Exit controlled loop
1. Entry controlled loop in C:
In such type of loop, the test condition is checked first before the loop is executed.
Some common examples of this looping statements are:
– while loop
– for loop
2. Exit controlled loop in C:
In such type of loop, the loop is executed first. Then condition is checked after block of statements are executed. The loop executed atleat one time compulsorily.
Some common example of this looping statement is:
– do-while loop