#include <iostream>
usingnamespace std;
int main () {
//Initializing:
int number = 0, base = 0;
int digit = 0, result = 0;
//Input:
cout<<"Number = ";
cin>>number; //Giving the input.
cout<<"Base = ";
cin>>base; //Giving the input.
//Procedure:
do {
digit = number%base; //Taking the single digit of the number.
result = number/base; //Doing the division and
number = result; //initialising "number" for the next loop.
cout<<digit;
} while (result >= 1);
//Terminating program:
return 0;
}
How do I swap the digits? Because this way it writes the digits backwards. I don't have any idea how to do that.