Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6.  
  7. /*
  8. Prompts user for entering a number in the specified range
  9. and stores value in memory
  10.  
  11. displays numbers from the input starting point up to 10
  12.  
  13. Validates input by checking whether number entered is between 1-10,
  14. display all of the numbers after the entered number in ascending order up to 10.
  15.  
  16.  
  17.  
  18. Prompts user to run again after previous run. Program runs again or exits
  19. bases on user input.
  20. */
  21.  
  22. int count()
  23. {
  24.     cout << endl << "Enter a number between 1 and 10 " << endl;
  25.    
  26.     int x = 0;//initialize
  27.     cin >> x;
  28.  
  29.     while (x < 11)//evaluate
  30.  
  31.     {
  32.         cout << x << " ";
  33.         x++;//increment
  34.     }
  35. }
  36.  
  37.  
  38.  
  39.  
  40. int main()
  41. {
  42.  
  43. count();
  44.  
  45. string answer;
  46. answer = "Y", "N";
  47.  
  48. cout << endl << "Would you like to run the program again? (Y for yes, N for no)  ";
  49.  
  50. cin >> answer;
  51.  
  52. while (answer == "Y")
  53. {
  54.     count();
  55. }
  56.  
  57. while (answer == "N")
  58. {
  59.     exit(1);
  60. }
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement