Modify the C++ program to calculate the factorial of a positive integer 'n'. Implement custom exception handling to handle negative input values and display "Negative input is not allowed. Please enter a non-negative integer." as an error message.
Exception Handling
Factorial of n
Report a typo
Sample Input 1:
5Sample Output 1:
120Write a program in C++
#include <iostream>
int main() {
int n, factorial = 1;
std::cin >> n;
try {
} catch () {
}
return 0;
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.