input base and power of the number and calculate the power of base (loop)

 



#include<stdio.h>
main ()
{
   int x, power=1;
   int y,i;

 printf("enter 2 number :");
 scanf("%d %d",&y,&x);
 //x=base
 //y=power
 
 i=1;
 while(i<=y)
 {
     power=power*x;
     i++;
 }

 printf("%d to the power of %d is %d\n ",x,y,power);

}

output :

enter 2 number :3 4
4 to the power of 3 is 64



Comments