#include<stdio.h>
#include<conio.h>
float power(float,int);
int main()
{
float x;
int n;
printf("Enter value Mantissa: ");
scanf("%f",&x);
printf("Enter value Exponent: ");
scanf("%d",&n);
if(n<0)
printf("result= %f",(1/(power(x,n))));
else
printf("result= %f",(power(x,n)));
getch();
return 0;
}
float power(float x,int n)
{
if(n==0)
return 1;
else
{
if(n<0)
return(x*power(x,n+1));
else
return(x*power(x,n-1));
}
}
#include<conio.h>
float power(float,int);
int main()
{
float x;
int n;
printf("Enter value Mantissa: ");
scanf("%f",&x);
printf("Enter value Exponent: ");
scanf("%d",&n);
if(n<0)
printf("result= %f",(1/(power(x,n))));
else
printf("result= %f",(power(x,n)));
getch();
return 0;
}
float power(float x,int n)
{
if(n==0)
return 1;
else
{
if(n<0)
return(x*power(x,n+1));
else
return(x*power(x,n-1));
}
}
No comments:
Post a Comment
Convey your thoughts to authors.