fork download
  1. #include <stdio.h>
  2.  
  3. int power(int a,int b){
  4. if (b==0) return 1;
  5. else return a*power(a,b-1);
  6. }
  7.  
  8. int main() {
  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 p=power(a,b);
  16. printf("%d raised to power %d is %d",a,b,p);
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5296KB
stdin
4
2
stdout
Enter the base: 
Enter the power: 
4 raised to power 2 is 16