int fun(int x,int y)
{
if(!x){ printf("%d",y);return y+1;}
if(!y){return fun(x-1,1);}
else return fun(x-1,fun(x,y-1));
}
int main()
{
printf("%d\n",fun(2,2));
return 0;
}
whst are the steps involved in finding output of the above program?
Output of program
Hi. You can add a few print statements to see the flow of the code…for example print inside each if block and then you will know when the code goes inside the if condition…similarly you can print the value of x and y at the beginning of the function so each function call would be clear.
Another method is to simply dry run the code.
Hey Amit, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.