fork download
  1. #include <stdio.h>
  2.  
  3. int counter = 0;
  4.  
  5. int calc(int a, int b) {
  6. int counter = 0;
  7. int c;
  8. printf("counter = %d\n", counter);
  9. counter++;
  10. printf("counter = %d\n", counter);
  11. if (b == 3)
  12. return (a * a * a);
  13. else {
  14. c = calc(a, b / 3);
  15. printf("a=%d b=%d counter=%d\n", a,b,counter);
  16. return (c * c * c);
  17. }
  18. }
  19.  
  20. int main() {
  21. calc(4, 81);
  22. printf("%d outside", counter);
  23. }
  24.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
counter = 0
counter = 1
counter = 0
counter = 1
counter = 0
counter = 1
counter = 0
counter = 1
a=4 b=9 counter=1
a=4 b=27 counter=1
a=4 b=81 counter=1
0 outside