homeworkhelp111

yes_no

Feb 7th, 2022 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main(){
  5.     //Declare our variables to store number and answer to yes/no question
  6.     int num;
  7.     string yes_no;
  8.  
  9.     //Start a do while loop
  10.     do {
  11.         //Ask a user to enter a number
  12.         cout << "Enter a number (0-9) ";
  13.         //Store the number in num variable
  14.         cin >> num;
  15.  
  16.         //Ask user if he wants to continue and store the answer in yes_no variable
  17.         cout << "Would you like to stop (yes/no) ";
  18.         cin >> yes_no;
  19.     } while (yes_no == "no"); //Continue in loop only when user enters no
  20.     return 0;
  21. }
Add Comment
Please, Sign In to add comment