1. ## need some help

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.

The code I'm using for the first function is:

Code:
```void rightToLeft(int num)
{
if (num < 10)
{
cout << num << endl;
}
else
{
cout << (num % 10) << endl;
rightToLeft(num/10);
}
}```
Any help would be greatly appreciated

2. cin>>num;
do
{
rem=num%10;
num=num/10;
cout<<rem<<"\n";
}
while(num>0);

maybe something like this...

3. Originally posted by ihsir
cin>>num;
do
{
rem=num%10;
num=num/10;
cout<<rem<<"\n";
}
while(num>0);

maybe something like this...
The one I'm having trouble with it outputting it in normal order, I already figured out how to do it in reverse order. Thanks, though. (sorry if I'm not makin much sense...its a bit late...probably the reason why this is giving me so much trouble, too!)

4. nevermind, got it:

Code:
```	int count = 1;
double temp = num;

while (temp > 10)
{
temp = temp / 10;
count++;
}

while (count > 0)
{
num = temp;
cout << num % 10 << endl;
temp = temp * 10;
count--;
}```
just need to manipulate that into a recursive function (since thats what the problem is on)

5. if you put the cout statement before the recursive call it will print out the digits in reverse order. If you the call to cout after the recursive call it will print them to screen in usual order.