Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int input;
  7. char action;
  8.  
  9. do
  10. {
  11. cout << "Do you want to continue? (Y/N)?" << endl;
  12.  
  13. cin >> action;
  14.  
  15. if (!cin.good())
  16. {
  17. cout << endl << "Rip" << endl;
  18. return 1;
  19. }
  20.  
  21. if (action == 'y' || action == 'Y')
  22. {
  23.  
  24. }
  25.  
  26. if (input == -999)
  27. {
  28. cout << endl << "Exiting" << endl;
  29. return 0;
  30. } else
  31. {
  32. int result = 1;
  33.  
  34. for (int i = 0; i < input; i++)
  35. result *= i + 1;
  36.  
  37. cout << "The factorial of " << input << " is: " << result << endl;
  38. }
  39. } while (input != -999);
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement