I'm too beginner and things I say may not be correct. (+My English is terrible)
You need to do it twice, I mean the while loop.
Take a look at this code:
using namespace std;
This code reverses a decimal number, for example:
123456789 will be 987654321 .
Your program is based on this algorithm, so it reverses your number, so you should do it twice:
FirstWay:First reverse number that user enters and then transfer it to the base he wants.
SecondWay:Do your while loop twice, but depends on the base the user wants, you need to calculate the modulo from that number.
In both ways you need to be careful about "ZERO"s, consider that a "0" is the last number of a number, so if you reverse it, it will be first and makes no sense.
(the FirstWay is better and more efficient.)
By the way I think there will be better ways, better ask a professional.