Source Code :
#include<stdio.h>
int power(int a,int b)
{
int i,p=1;
for(i=1;i<=b;i++)
p*=a;
return p;
void main()
{
int x,n,p;
clrscr();
printf("\nEnter the Value of 'x' : ");
scanf("%d",&x);
printf("\nEnter the Value of 'n' : ");
scanf("%d",&n);
p=power(x,n);
printf("\nPower : %d",p);
getch();
}
Output :
Enter the Value of ‘x’ : 2
Enter the Value of ‘n’ : 3
Power : 8
No comments:
Post a Comment