Question: Using C++ Write a programmer defined function that provides the factorial of a positive integer. Your main function should ask the user for the value

Using C++

Write a programmer defined function that provides the factorial of a positive integer. Your main function should ask the user for the value of an integer and pass this value to your programmer defined function. The programmer defined function needs to calculate the factorial, and return the factorial. You will need to display the factorial to the user in the main function.

Make sure: i) If the user enters 0, your function should return 1.

ii) If the user enters a negative number, your program should return -1. In your main function, display a suitable error message in this case.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!