NIELIT O Level January 2016 Solve paper
Q 7 b.(ii) while and do..while loops
Iteration
statements allow the set of instructions to execute repeatedly till the
condition doesn’t turn out false. The Iteration statements in C for while loop
and do while loop. These statements are commonly called loops. Here, the main
difference between a while loop and do while loop is that while loop check
condition before iteration of the loop, whereas do-while loop, checks the
condition after the execution of the statements inside the loop.
BASIS FOR COMPARISON
|
WHILE
|
DO-WHILE
|
Syntax
|
while ( condition) {
statements; //body of loop } |
do{
. statements; // body of loop. . } while( Condition ); |
Controlling Condition
|
In 'while' loop the controlling condition
appears at the start of the loop.
|
In 'do-while' loop the controlling
condition appears at the end of the loop.
|
Iterations
|
The iterations do not occur if, the
condition at the first iteration, appears false.
|
The iteration occurs at least once even
if the condition is false at the first iteration.
|