Question: *** USING C++ *** Topics A loop within a loop while statement for statement Description Write a program that computes the factorial of a positive

*** USING C++ ***

Topics

A loop within a loop

while statement

for statement

Description

Write a program that computes the factorial of a positive whole number. The program asks the user to enter a positive whole number. It computes the factorial of the number provided and displays the result. The program does this repeatedly. In one execution of the program the user may obtain the factorial of several numbers one after the other.

Notes

The factorial of a number n is the product of all numbers from 1 to n. The factorial of a few numbers is presented below:

Factorial of 0 = 1 (by definition).

Factorial of 1 = 1

Factorial of 2 = 1 * 2 = 2

Factorial of 3 = 1 * 2 * 3 = 6

Factorial of 4 = 1 * 2 * 3 * 4 = 24

Factorial of 5 = 1 * 2 * 3 * 4 * 5 = 120

Test Run

Enter a number:

5

The factorial of 5 is 120

Enter a number:

6

The factorial of 6 is 720

Enter a number:

0

The factorial of 0 is 1

Enter a number:

7

The factorial of 7 is 5040

Enter a number:

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!