posted 10 years ago
H, i am currently learning recursion, and i have a query.
I have a program that receives user input, and outputs the decimal input into binary form.
In my recursive function, i have a if else loop to check if operation is completed. The problem i face is this.
The final return, when input finally hits zero is concatenating 0 to whatever i have this far. e.g. Decimal 10 should give 1010, but because of the "return 0", instead of getting
1010+0, i am getting 10100.
I can solve the problem by creating a variable sum,and passing along, but i am just curious why the final return 0 is giving me not a +0,but a concatenate 0.
Thanks in advance for the help rendered.