Topic 6: The While Loop
The while loop continues to loop while some condition is true.
When the condition becomes false, the looping is discontinued.
Look ate the program:

1. Here an integer "count" is declared.
2. The count is given initial value 0.
3. The while loop>>>here until the value of 'count' is less than 6 the loop continues.
4. Then count is incremented.
After while loop the statements below it executes.
In the first case the value is initial value ie, '0'.
Then the while loop executes successfully as '0' is less than '6'.
The 'count' is incremented by one (count = count + 1;).
From here the control goes back to while loop as these are enclosed inside while loop.
The value of 'count' becomes 1.
This is continued until the value becomes 6.
and so the program runs and produce results as shown in the figure.
0 comments: