Problem 1 : Find a to power n without math library.
Solution :
#include<stdio.h>
int main()
{
int i,j,test,n,a;
scanf("%d",&test);
for(i=1;i<=test;i++)
{
scanf("%d",&a);
scanf("%d",&n);
int product=1;
for(j=1;j<=n;j++)
{
product*=a;
}
printf("%d\n",product);
}
}
No comments:
Post a Comment