I have completed the question and my code works but I just want to find out whether I interpreted it correctly.
The question say:
Write a recursive function reverseDigits that takes an integer as a parameter and returns the
number with the digits reversed. Also write a program to test your program.
I assume the number must be returned as an integer and cannot simply be converted to a string for aesy manipulation.
My problem though is that my recursive function takes 2 parameters. The number and the reverse of the number.
The prototype looks as follows:
Language: C++
int reverseDigits(int num, int rev);
in the next step of my general case, it takes the number/10 and a temp variable which is calculated by reverse*10+the mod of the number.
my base case just returns the reverse if the number = 0.
I am a bit weary of posting the code here so if anyone can tell me whether my approach was correct, I can consider this problem solved.
Thanks
Chris
Chris Botha
=============================
Far and away the best prize that life has to offer is the chance to work hard at work worth doing.
Theodore Roosevelt