C While Loop
Loops
Loops are used to execute a set of instructions or functions repeatedly when some conditions become true.
While Loop
A while loop allows a part of the code to be executed multiple times depending upon a given boolean condition. It can be viewed as a repeating if statement. The while loop is mostly used in the case where the number of iterations is not known in advance.
while (condition) {
// code block to be executed
}
The Do/While Loop
In do-while loops also the loop execution is terminated on the basis of test conditions. The main difference between a do-while loop and the while loop is in the do-while loop the condition is tested at the end of the loop body.
do {
// code block to be executed
}
while (condition);