do {
// body of loop;
}
while (condition);
do {
// codes;
}
while (testExpression);
while (/*condition*/) {
//implementation
}
while (true) {
cout << "hello" << endl;
}
while(condition)
{
statement(s);
}
// Do while loop
// C++ Program to print numbers from 1 to 5
#include <iostream>
using namespace std;
int main() {
int i = 6;
// while loop from 1 to 5
while (i <= 5) {
cout << i << endl;
i++;
}
return 0;
}
int i = 0;
while (i < 5) {
cout << i << "
";
i++;
}
while (x){ ... }
// Executes a statement repeatedly until the value of the condition expression
//becomes false. The test takes place after each iteration.
do {
//statement
} while(condition);
//Executes a statement repeatedly, until the value of condition becomes false.
//The test takes place before each iteration
while(condition) {
statement
}
while