fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double power (float b, int e);
  5.  
  6. int main()
  7. {
  8. float base = 2.0f;
  9. int exp = 4;
  10. double res;
  11. res = power(base,exp);
  12. printf("%f\n", res);
  13. return 0;
  14. }
  15.  
  16. double power(float b, int e)
  17. {
  18. double r;
  19. for (r=1; e>0; r*=b,e--);
  20. return r;
  21. }
Success #stdin #stdout 0s 5456KB
stdin
Standard input is empty
stdout
16.000000