#include<stdio.h>
#include<conio.h>
int power(int,int);
int main()
{
int f,a,b;
printf("Enter the base: ");
scanf("%d",&a);
printf("Enter the positive exponent: ");
scanf("%d",&b);
f=power(a,b);
printf("The result of %d raised to the power of %d is %d",a,b,f);
return 0;
}
int power(int a,int b)
{
if(b==1)
return a;
else
return (a*power(a,b-1));
}
#include<conio.h>
int power(int,int);
int main()
{
int f,a,b;
printf("Enter the base: ");
scanf("%d",&a);
printf("Enter the positive exponent: ");
scanf("%d",&b);
f=power(a,b);
printf("The result of %d raised to the power of %d is %d",a,b,f);
return 0;
}
int power(int a,int b)
{
if(b==1)
return a;
else
return (a*power(a,b-1));
}
No comments:
Post a Comment
Convey your thoughts to authors.