Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am writing a program in C using functions. I need to add the prototype for a f

ID: 3679081 • Letter: I

Question

I am writing a program in C using functions. I need to add the prototype for a factorial function. I also need to call an exponential and factorial function inside the code. I have no clue how to do this. I know that the prototype for the exponent is int exp(int base, int pow). Please help thank you!! I am writing a program in C using functions. I need to add the prototype for a factorial function. I also need to call an exponential and factorial function inside the code. I have no clue how to do this. I know that the prototype for the exponent is int exp(int base, int pow). Please help thank you!!

Explanation / Answer

#include <stdio.h>

int rec(int);
int getexp(int,int);
int main()
{
int fact,base,pow,expr,exp1;

printf("Enter base number:");
scanf("%d",&base);
printf("Enter exponent number:");
scanf("%d",&pow);
fact=rec(base);
printf("Factorial value-%d ", fact);
expr= getexp(base,pow);
printf("exponent value-%d ", expr);
return 0;
}

int getexp(int base, int pow)
{
long long int value=1;
while (pow!=0)
{
value*=base; /* value = value*base; */
--pow;
}
return(value);
}

int rec(int base)
{
int f;
if(base==1)
return(1);
else
f=base*rec(base-1);
return(f);

}

OutPut:

Enter base number:3 Enter exponent number:2 Factorial value-6 exponent value-9

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote