DIR Return Create A Forum - Home
---------------------------------------------------------
techsuns
HTML https://techsuns.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: OutPut of a Program
*****************************************************
#Post#: 465--------------------------------------------------
Recursion..........
By: kpr29 Date: March 14, 2013, 12:32 am
---------------------------------------------------------
@Boss: Give the output for the below program........ Whoever
gives the correct answer first, will get gobi from sampath......
int foo(int k)
{
if ( k%2 )
{
return (k++);
}
else
return foo(foo( k - 1 ));
}
int main()
{
printf(" %d ", foo(20));
printf(" %d", foo(19));
return 0;
}
#Post#: 466--------------------------------------------------
Re: Recursion..........
By: adi Date: March 14, 2013, 1:22 am
---------------------------------------------------------
19 19
please explain now
#Post#: 467--------------------------------------------------
Re: Recursion..........
By: kpr29 Date: March 14, 2013, 2:29 am
---------------------------------------------------------
@Adi: What explanation u want........ u got the answer
right.........
kp.
#Post#: 468--------------------------------------------------
Re: Recursion..........
By: adi Date: March 14, 2013, 4:26 am
---------------------------------------------------------
@kp, i just wanted someone to give it a try after knowing the
solution and explain the result. ;)
#Post#: 471--------------------------------------------------
Re: Recursion..........
By: dinesh Date: March 15, 2013, 2:04 am
---------------------------------------------------------
@KP : I expected tougher microsoft level questions from you.
#Post#: 475--------------------------------------------------
Re: Recursion..........
By: kpr29 Date: March 15, 2013, 2:33 am
---------------------------------------------------------
@Dinesh: I posted some questions like design algorithm......
views only was not there, so I decided to post simple but bit
tricky questions, so that atleast some one like me will be
happy to participate......... For microsoft questions first
answer to my questions in the algorithm section... Once I see
the outcome i will post some more.
kp
*****************************************************