Question: Fill in the following program so that the user can choose a function, input parameters, and receive the correct calculation. #include //function prototypes int exp(int

 Fill in the following program so that the user can choose
a function, input parameters, and receive the correct calculation. #include //function prototypes
int exp(int base, int exponent); [ Select) fact( (Select) //main function int

Fill in the following program so that the user can choose a function, input parameters, and receive the correct calculation. #include //function prototypes int exp(int base, int exponent); [ Select) fact( (Select) //main function int main() { int n, pow, result, option; printf("What would you like to do? "); printf("1 - Calculate a power. "); printf("2 - Calculate a factorial. "); scanf("%d", &option); while (option != 1 && option != 2) { printf("Sorry, that was not a valid option. "); printf("What would you like to do? "); printf("1 - Calculate a power. "); printf("2 - Calculate a factorial. "); scanf("%d", &option); } if (option 1) { printf("Please enter the base value. "); scanf("%d", &n): printf("Please enter the exponent. "); scanf("%d",&pow); while (pow= 13) printf("Sorry, that was not a valid number. "); printf("Please enter a value. "); scanf("%d", &n); 3 result = fact(n): printf("%d! = %d", n, result); } return 0; 3 W Precondition: base is a real number, exp >=0 // Postcondition: Returns base raised to the exp power. int exp(int base, int exponent) { int i, result = 1; for(i=0; i

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!