Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- //Declare our variables to store number and answer to yes/no question
- int num;
- string yes_no;
- //Start a do while loop
- do {
- //Ask a user to enter a number
- cout << "Enter a number (0-9) ";
- //Store the number in num variable
- cin >> num;
- //Ask user if he wants to continue and store the answer in yes_no variable
- cout << "Would you like to stop (yes/no) ";
- cin >> yes_no;
- } while (yes_no == "no"); //Continue in loop only when user enters no
- return 0;
- }
Add Comment
Please, Sign In to add comment