Friday, August 7, 2009

THE WHILE LOOP

The while loop is a for loop stripped of the initiliazation and update parts,it has a just a condition and a test condition and a body.
While(test condition)
body
Multiple statement in the while loop:
As earlier said mutiple statements can be return in a while loop by including the statements in the braces.
The Do while loop:
we have now seen the for loop and the while loop.the third c++ is the do while loop from the other two because it first execute the body then it tries to evaluate the test expression.If the condition evaluates to true than a new cycle of execution and termination begins otherwise it terminates the loop always executes at least once because its programflow that pass the through the body of the loopbefore reaching the test.Here is the syntax.
do
body;
while(test expression)

No comments:

Post a Comment