Coverting Decimal to Binary, Hex, Octal

I'm currently taking a class in C++. The teacher isn't clear and I'm not quite sure on what to do. I really need help

1. dtob – converts a decimal number to binary

2. dtoh – converts a decimal number to hex

3. dtoo – converts a decimal number to octal

4. btoh – converts a binary number to a hex

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
#include <iostream>
#include <string>

using namespace std;

int main()

{
	int decimal;
	string binary, hex, octal;

	cout << "Eenter a decimal number :";
	cin >> decimal;

	binary = dtob(decimal);
	hex = dtoh(decimal);
	octal = dtoo(decimal);

	cout << decimal << " to binary is " << binary << endl;
	cout << decimal << " to hex is " << hex << endl;
	cout << decimal << " to octal is " << octal<< endl;

	hex = btoh(binary);
	cout << binary << " to hex is " << hex << endl;

	system("pause");
	return 0;
}


5. Create a function that returns the largest number of two numbers.

Thanks!
Looks like you need to create 5 functions that do the required conversions.

Topic archived. No new replies allowed.