Laurand Osmeni

Let's build a faster web.

e-mail

How do I use the Do While Loop in C++.

The do while loop is the upside down of while loop, because inside the do body will run code first, and then the while follows and runs the code test.

Creating a variable x with the value 1.

int x = 1;

Now the syntax of do while loop is do.

do

Do while loop will run the code one time.

cout << "We have lab on friday" << endl;

x = x++;

The while loop will be less than 10 and test the code, so on the screen will be printed 10 times.

while (x <= 10);

It is easier to use, but make sure you check the while loop if you haven't looked yet.

Watch live in action creating the program, or scroll below to copy the entire code.

If Else Statement
How do I use Do While Loop in C++.
#include <iostream> using namespace std; int main () { int x = 1; do { cout << "We have lab on friday" << endl; x = x++; }while (x <= 10); return 0; }

Feel free to use the code.

Last update .

Navigate between pages.
Top