fork download
  1. #include <stdio.h>
  2.  
  3. double power(double n, int p) {
  4. double pow = 1;
  5. for (int i = 1; i <= p; i++) pow *= n;
  6. return pow;
  7. }
  8.  
  9. int main() {
  10. printf("%.0f\n", power(5, 2));
  11. printf("Enter n and p (n^p): ");
  12. double n;
  13. int p;
  14. scanf("%lf", &n);
  15. scanf("%d", &p);
  16. printf("The pow is: %.0f\n", power(n, p));
  17. }
  18.  
  19. //https://pt.stackoverflow.com/q/296497/101
Success #stdin #stdout 0s 4544KB
stdin
2
3
stdout
25
Enter n and p (n^p): The pow is: 8