Question: PLEASE explain each line of this code SOURCE CODE: #include float power(float x,int n); int main(){ float x,result; int n; printf( Enter a value for
PLEASE explain each line of this code
SOURCE CODE:
#include
float power(float x,int n);
int main(){
float x,result;
int n;
printf(" Enter a value for x: ");
scanf("%f",&x);
printf(" Enter a value for n: ");
scanf_s("%d",&n);
result=power(x,n);
printf(" %f raised to the power %d = %f ",x,n,result);
return 0;
}
float power(float y,int m){
if(m==0 ){
return (1.0);
}
else if (m>=1){
return(y * power(y,m-1));
}
else{
return (1.0/(y*power(y,-m-1)));
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
