Some problem in base conversion

Hi there!
I have some problem in base conversion.

There is my work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <sstream>
using namespace std;

int main()
{
	int value = 0;
	int b = 0;
	cout << "Enter a base 10 number: ";
	cin >> value;
	
	cout << "Enter the base you want to convert the number to: ";
	cin >> b;

	string convert(value, b);
	cout << "The value " << value <<  " (base 10) " <<  " is " <<  factorial;
	system("pause");
	return 0;
}

string convert(int value, int b)
{
	if(b > 9 && b < 1)
	{
		return 0;
	else
		return convert (value / b, b);
	}
}

um....not very complicated code, and have some mistake.
In this case, I don't know the program should consist of a main function together with a recursive function convert.
string convert(int value, int b).
And how to check the base.
Please give me some tips.
Last edited on
when calling functions we don't include the return type:
string convert( value, b ); should be convert( value, b )

what is that factorial in your cout ?, have you defined that already ?

Remember that string is used for series of characters which is indeed not needed in your code,
isn't int should be the perfect return type of convert instead, since all the values you will need require integers( string is useless )

And you should declare a variable that will hold the data returned by convert
Last edited on
Topic archived. No new replies allowed.