Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Program to calculate the factorial of a given number\n";
- cout << "----------------------------------------------------\n";
- cout << "Enter n: ";
- int n;
- cin >> n;
- int ans = 1;
- for (int i = 1; i <= n; i++)
- {
- ans *= i;
- }
- cout << "The Factorial of " << n << " is: " << ans << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment