Recursion Problem
ok, heres my code
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void convert (int num1, int base1)
{
int remainder;
remainder = num1 % base1;
if (num1 / base1 == 0)
{
if (remainder <= 9)
cout << remainder;
else if (remainder > 10)
{
cout << static_cast <char> (remainder + 55);
}
}
else
{
num1 /= base1;
convert (num1, base1);
}
}
int main()
{
int base;
int num;
cout << "Please enter the base: ";
cin >> base;
cout << "Please enter the number: ";
cin >> num;
cout << "The converted number is ";
convert(num, base);
cout << endl;
system ("pause");
return 0;
}
what i am trying to do here is when i send in two numbers, a base and a number, i am trying to convert it into a new output like this
i send in my base 16 and my number by 575
i should get something like 3F
but i always get 2
does anybody have any ideas?
|