There's nothing wrong with your code, it's the conventional recursive inorder traversal. Perhaps if you explained what you expected to happen that differs from what actually happens, someone can help you change the code to meet your needs.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
It is not behaving unexpectedly. When the "inorder(r->left)" is called for the last time with a NULL pointer, it indeed just returns without having executed the loop. Then, the programm just continues to the next statement, which in your case is the printf function.
mikrosfoititis
Junior Poster in Training
74 posts since Nov 2011
Reputation Points: 18
Solved Threads: 11
But plz tell me the reason why this code is behaving unexpectedly ?
Your expectations are wrong, so the code will behave unexpectedly for you. Duh.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
mikrosfoititis
Junior Poster in Training
74 posts since Nov 2011
Reputation Points: 18
Solved Threads: 11