Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sebastian Moore
- //CS 52 Spring 2019
- #include <iostream>
- using namespace std;
- int
- main ()
- {
- int num1;
- unsigned int x;
- unsigned long long factorial = 1;
- bool positive = true;
- while (positive == true)
- {
- cout << "Enter an integer: ";
- cin >> num1;
- for(int x = 1; x <= num1; ++x)
- {
- factorial *= x;
- }
- cout << num1 << "! = " << factorial;
- }
- if (num1 > 0)
- {
- positive = false;
- }
- else
- {
- cout << "Error: number must be positive." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement