#include<stdio.h>
int power(int *,int *);
int main()
{
int base=0,expo=0,pow=0;
printf("Enter the base number:");
scanf("%d",&base);
printf("Enter the exponent:");
scanf("%d",&expo);
pow=power(&base,&expo);
printf("Power of given base is %d",pow);
getch();
return 0;
}
int power(int *base,int *expo)
{
int x,size;
size=*base;
for(x=1;x<*expo;x++)
{
*base=*base * size;
}
return *base;
}
int power(int *,int *);
int main()
{
int base=0,expo=0,pow=0;
printf("Enter the base number:");
scanf("%d",&base);
printf("Enter the exponent:");
scanf("%d",&expo);
pow=power(&base,&expo);
printf("Power of given base is %d",pow);
getch();
return 0;
}
int power(int *base,int *expo)
{
int x,size;
size=*base;
for(x=1;x<*expo;x++)
{
*base=*base * size;
}
return *base;
}
No comments:
Post a Comment