+ 2
I cannot understand what does "do...while" does?
plz anyone can explain me?
3 Respuestas
+ 1
do...while is one of the loops that the C++ language provides along with the 'for' loop and the 'while' loop. The basic function of a loop is to execute the set of statements included in the loop everytime the given condition is satisfied.
The only difference between do...while and other loops is that do...while loop executes the statements atleast once irrespective of the condition whereas for the other two loops the condition must be satisfied every time the loop is executed.
Please do hit a 'like', if you find answer helpful!
- 1
Do...while loop have at least one iteration. First example: do{cout<<'HELLO';}while(true); will print to the screen HELLO once. Second example is do{cout<<'HELLO';}while(false); will print to the screen HELLO infinite number of times or until you force program to exit manually (try CTRL + C).
- 2
Do as long as value is false. For example do { cin >> a; }while ( a = 10 ) You will have to type number as long as integer won't equal 10