0

[c++] Give me some example with Do...While

Hey guys, I don't understand yet how works do and while loops. Can you do me some example? I mean something other then "number 1, number2, number3"

19th Dec 2018, 12:02 PM
Sirut
Sirut - avatar
2 Answers
+ 5
int i = 0; do { std::cout << "Printed: " << i << std::endl; i++; } while (i <= 10); // Prints "Printed: <iter>" ten times while int i <= 10.
19th Dec 2018, 12:28 PM
Dread
Dread - avatar
+ 2
cout << "Please enter a number between 1 and 10!"; int number{}; do { cin >> number; } while (number<1||number>10);
19th Dec 2018, 1:07 PM
HonFu
HonFu - avatar