fork download
  1. #include <stdio.h>
  2. int power(int a,int b){
  3. if(b==1) return a;
  4. int x= power(a,b/2);
  5. int ans = x*x;
  6. return ans;
  7. }
  8. int main(void) {
  9. int a;
  10. printf("Enter the base: \n");
  11. scanf("%d",&a);
  12. int b;
  13. printf("Enter the power: \n");
  14. scanf("%d",&b);
  15. int x= power(a,b);
  16. printf("The value of %d raise to power %d is %d",a,b,x);
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5316KB
stdin
2
8
stdout
Enter the base: 
Enter the power: 
The value of 2 raise to power 8 is 256