Question: Let n be a nonnegative integer. The factorial of n, written n!, is defined by 0!=1, n! =1*2*3*...*n if n >= 1. For example, 4!
Let n be a nonnegative integer. The factorial of n, written n!, is defined by 0!=1, n! =1*2*3*...*n if n >= 1. For example, 4! = 1*2*3*4 = 24. Write a program that prompts the user to enter a nonnegative integer and outputs the factorial of the number.
Output format:
4! = 24
0! = 1
Notes: - You must check if the entered integer is non-negative. If it is negative, keep asking the user to input a non-negative integer. You can use infiniteĀ
Step by Step Solution
3.59 Rating (152 Votes )
There are 3 Steps involved in it
include using namespace std int main declare variables int n double result p... View full answer
Get step-by-step solutions from verified subject matter experts
