Ok, what I'm trying to do is take an integer and display each digit, one per line, in reverse order:
// num = 123
//displays
3
2
1
and in normal order
// num = 123
1
2
3
I've figured out how to do the first one with % and / but am unsure how to do this to the next one...? I have a feeling its just a minor change but its beyond me right now. :confused:
The code I'm using for the first function is:
Any help would be greatly appreciated :)Code:void rightToLeft(int num)
{
if (num < 10)
{
cout << num << endl;
}
else
{
cout << (num % 10) << endl;
rightToLeft(num/10);
}
}