This is a recursive program. But I don't understand the sequence of events which take place during this program
#include<stdio.h> count(int); main() { int x=5; count(x); } count(int y) { if(y>0) { count(--y); printf("%d ",y); } } the output is:
4 3 2 1 0 ... But I don't get what happens when the first time count(5) is called and when count(4) is called. Does the control immediately go to the start of the function? Or first it prints the value of y and then again goes to the start of the function count()?
gdbafter having compiled withgcc -Wall -g), run the program step by step or at least with a breakpoint incountvoid main; it uses assumed returnint, which is pre-ISO (K&R) C.voidwhen I posted.