Hi,
I have the below code which I do not understand. The problem is: which instruction is to be executed after pb(n/2) is called? My guess is that once pb(n/2) is encountered, program goes to void pb(int n) and starts executing again from there. But that means that putchar() is never executed. Wondering if someone can show me how to trace this small program.
The following table is a list of variables and statements defining how I think the program is executing.Code:#include <stdio.h> /*function declaring*/ void pb(int n) { if (n != 0) { pb(n/2); putchar('0' + n % 2); } } int main() { pb(10); getchar();getchar(); return 0; }
http://i44.tinypic.com/21an0ol.png
http://i41.tinypic.com/14cd3t4.png