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