fork download
  1. #include <stdio.h>
  2.  
  3. int mypower(int base, int exponent);
  4. int x, y, result = 0;
  5.  
  6. int main()
  7. {
  8. scanf("%d", &x);
  9. scanf("%d", &y);
  10. result = mypower(x, y);
  11. printf("%d raised to the power of %d is %d", x, y, result);
  12. return 0;
  13. }
  14.  
  15. int mypower(int base, int exponent)
  16. {
  17. int count = 1;
  18. int total = base;
  19. while (count < exponent)
  20. {
  21. total = base * total;
  22. count++;
  23. }
  24. return total;
  25. }
  26.  
Success #stdin #stdout 0s 9432KB
stdin
11 4
stdout
11 raised to the power of 4 is 14641