fork download
  1. #include <stdio.h>
  2.  
  3. int power(int a, int b){
  4. int c = 1;
  5. while (b > 0)
  6. {
  7. c *= a;
  8. b--;
  9. }
  10.  
  11. return c;
  12. }
  13.  
  14. int main(void) {
  15. int x,n,y;
  16. x = 2;
  17. n = 4;
  18. y = power(x,n);
  19. printf("%d の %d 乗は %d",x,n,y);
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
2 の 4 乗は 16