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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started