added a small statement (#23119)
* added a small statement * Fixed formatting
This commit is contained in:
committed by
Manish Giri
parent
3ba002f2b6
commit
d8861ab98a
@ -2,8 +2,9 @@
|
||||
title: do while loop
|
||||
---
|
||||
## Do While Loop
|
||||
This is just like the `while` and `for` loop but the only difference is that the code in its body is executed once before checking the condition.
|
||||
|
||||
The `do while loop` is almost the same as the while loop. The `do while loop` has the following form:
|
||||
The `do while` loop has the following form:
|
||||
```cpp
|
||||
do
|
||||
{
|
||||
@ -18,7 +19,9 @@ Note: Remember to use a semicolon ';' at the end of the condition.
|
||||
|
||||
The do-while loop is used whenever you are sure that a particular process(within the loop) has to be performed at least once. It has many advantages like not initializing the checking variable(eg- char addmore='Y') etc. The semicolon at the end of while is a must.
|
||||
|
||||
Do something first and then test if we have to continue. The result is that the do block runs at least once. (Because the expression test comes afterward). Take a look at an example:
|
||||
Do something first and then test if we have to continue. The result is that the do block runs at least once. (Because the expression test comes afterward) . Take a look at an example:
|
||||
|
||||
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
Reference in New Issue
Block a user