Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c program You will create your string as a character pointer, not a character array. You will allocate memory for your string using malloc or
c program
You will create your string as a character pointer, not a character array.
You will allocate memory for your string using malloc or calloc.
You will use as inputs: 6, 3, 12, 0, and -1 (to quit).
NO GLOBALS.
3. Write a function fact_calc that takes a string output argument and an inte- ger input argument n and returns a string showing the calculation of nl. For example, if the value supplied for n were 6, the string returned would be "6!-6X5 X 4 X 3 X 2x 1- 720". Write a program that repeatedly prompts the user for an integer between 0 and 9, calls fact_calc and out puts the resulting string in a box of asterisks of the right size to surround the result. If the user inputs an invalid value, the program should display an error message and reprompt for valid input. Input of the sentinel -1 should cause the input loop to exit. Sample run: Enter an integer between 0 and 9 or -1 to quit-6 *6! = 6 x 5 x 4 x 3 x 2 x 1 = 720 * Enter an integer between 0 and 9 or -1 to quit => 12 Invalid entry Enter an integer between 0 and 9 or -1 to quit-> *0-1 Enter an integer between and 9 or -1 to quit-1Step 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