filmov
tv
Lecture #26-Do while loop with example in C++ 2020-Do while c++

Показать описание
DO WHILE!!
The do...while loop is a variant of the while loop with one important difference: the body of do...while loop is executed once before the condition is checked.
Its syntax is:
do {
// body of loop;
}
while (condition);
Here,
The body of the loop is executed at first. Then the condition is evaluated.
If the condition evaluates to true, the body of the loop inside the do statement is executed again.
The condition is evaluated once again.
If the condition evaluates to true, the body of the loop inside the do statement is executed again.
This process continues until the condition evaluates to false. Then the loop stops.
The do...while loop is a variant of the while loop with one important difference: the body of do...while loop is executed once before the condition is checked.
Its syntax is:
do {
// body of loop;
}
while (condition);
Here,
The body of the loop is executed at first. Then the condition is evaluated.
If the condition evaluates to true, the body of the loop inside the do statement is executed again.
The condition is evaluated once again.
If the condition evaluates to true, the body of the loop inside the do statement is executed again.
This process continues until the condition evaluates to false. Then the loop stops.