Issue
In factorial.cpp, the factorial calculated for negative number is wrong. Here is the output:
Enter a positive integer: -5
Factorial of -5 = 1
Expected Outcome
Factorial should be calculated for only positive number and exist for negative inputs.
Possible Fixes
Adding if-else condition may fix this problem.
Issue
In
factorial.cpp, the factorial calculated for negative number is wrong. Here is the output:Expected Outcome
Factorial should be calculated for only positive number and exist for negative inputs.
Possible Fixes
Adding if-else condition may fix this problem.