|
While loop - Wikipedia, the free encyclopedia
In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition. The while loop can be thought of as a ...
en.wikipedia.org/wiki/While_loop |
|
Do while loop - Wikipedia, the free encyclopedia
In most computer programming languages, a do while loop , sometimes just called a do loop , is a control flow statement that allows code to be executed repeatedly based on a given Boolean conditio...
en.wikipedia.org/wiki/Do_while_loop |
|||
|
|
|||
|
|||
|
|||
|
Like with the if statement, you can group multiple statements within the same while loop by surrounding a group of statements with curly braces, or by using the alternate syntax:
|
|||
|
Examples - while loops ... #include <iostream.h>; int main ( ); { const int HIGHGRADE = 100; int num = 0; float grade, total, average; grade = total = average = 0.0; cout << "Please enter the quiz grades" << endl; cout << "When all grades have been entered, enter any number greater than 100" << endl;
|
|||
|
9.2. The while loop ... The while construct allows for repetitive execution of a list of commands, as long as the command controlling the while loop executes successfully (exit status of zero). The syntax is: ... 9.2.2.3. Using keyboard input to control the while loop...
|
|||
|
The bracket construct in a while loop is nothing more than our old friend, the test brackets used in an if/then test. In fact, a while loop can legally use the more versatile double-brackets construct (while [[ condition ]]).
|
|||
|
The while Loop ... The while loop loops through a block of code while a specified condition is true. ... The do...while loop is a variant of the while loop. This loop will execute the block of code ONCE, and then it will repeat the loop as long as the specified condition is true.
|
Copyright © 2009, Dictionary.com, LLC. All rights reserved.