Loops are used in programming to repeat a specific block until some end condition is met. There are three loops in C programming:
- while loop
- do…while loop
- for loop
A while loop in C programming repeatedly executes a target statement as long as a given condition is true.
The general form of while is as Follows:
intialise loop counter;
while (test loop counter using condition)
Increment / decrements loop counter;
The do ……while loop.
The syntax of do … while loop is as fallows.
} while(this condition is true);
For loop :
The general form of for statement is as under:
for ( initialize loop counter; test counter; increment counter)