Question: Problem: Create a program that uses a function to calculate the factorial of a positive whole number and a function to validate user s input.

Problem: Create a program that uses a function to calculate the factorial of a positive whole
number and a function to validate users input. Your program should contain two programmer-
built functions in addition to main. No selection structures should be used in this program.
Do not use the same identifier in more than one function.
Your main function should prompt the user to enter a whole number less than or equal to 20.
Call a function to verify that the entered number is less than or equal to twenty, call the function
to calculate the factorial, return the factorial to main and then output the factorial of the entered
number. Next the main function should output the entered number and the resultant factorial.
Consider carefully what integer data type you should use for the resultant factorial.
The function to validate input should accept the users entered value then use a while loop to
prompt the user to re-enter if the entered value was less than 1 or greater than 20. The validated
value should be returned to the function call in main.
The function to calculate the factorial should accept the validated entered value, define any
needed local variables that are needed, and then calculate the factorial using a loop. The factorial
should be returned to the function call in main.
Remember that function definitions should be after the main function and your code
should employ function declarations (prototypes). In addition to the overall introductory
comments your program should have comments immediately before each function stating
the purpose of that function, input to the function (what parameters are passed to it),
output from the function (values returned or sent back to the function call plus any output
of values within the function), and processing that occurs within the function.
Take the time to confirm your submissions.

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 Programming Questions!