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