answersLogoWhite

0

#include
#include

using std::cin;
using std::cout;
using std::endl;
using std::tolower;

inline void decToHexOct(unsigned int number, char base);

int main()
{
cout << endl << "Enter a number: ";
unsigned int number = 0;
cin >> number;

cout << endl << "Choose base:"
<< endl << "h//H for Hex"
<< endl << "o//O for Octal"
<< endl;
char base = 'h';
cin >> base;

decToHexOct(number, base);

system("PAUSE");
return 0;
}

inline void decToHexOct(unsigned int number, char base)
{
if (tolower(base) == 'h')
{
cout << endl << "Number in hex is: " << std::hex << std::showbase << number
<< endl;
}
else if (tolower(base) == 'o')
{
cout << endl << "Number in octal is: " << std::oct << std::showbase << number
<< endl;
}
else
{
cout << endl << "Wrong base...";
system("PAUSE");
exit(1);
}
}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you convert 3.68 into a decimal?

3.68 is already a decimal and does not need to be converted.


Convert 18 to a decimal?

18 (eighteen) is an integer and does not need to be "converted to a decimal"1/8 (one eighth) is a fraction and can be converted into a decimal: 0.125


How convert 123789 into binary?

Converted from decimal to binary, 123789 is equal to 11110001110001101.


What is 12 percent converted to a decimal?

To convert a percentage to a decimal, divide by 100: 12 % = 12 &divide; 100 = 0.12


How do you convert octal to binary with 2 decimal nos?

The conversion of octal number to binary can be obtained by using two methods. First, it can be converted into decimal and then obtained decimal is converted into binary. In the second method


What is the answer to 0.02 converted into a percent?

to convert a decimal to percent, multiply by 100. 0.02 = 2%


How do you convert fraction to decimal and vise versa?

Decimals can only be converted into fractions if they are rational numbers


Convert 0.02687 into a whole number?

A whole number is a number that is not a decimal or fraction. Since 0.02687 is a decimal, it cannot be converted into a whole number.


How do you convert 38 to decimal?

38 is an integer, it does not need to be converted. 3/8 is a fraction, it is equal to 0.375


Do equivalent fractions convert to the same decimal?

NoImproved Answer:-Yes equivalent fractions can be converted into identical decimals.


What are the numbers in the smallest group of repeating digits when 4111 is converted to a nonterminating decimal?

4111 is an integer and so there is no sensible way to convert it into a repeating decimal.


Convert 28.25 to a whole number?

If a decimal could be converted to a whole number, we wouldn't need decimals for anything. Or fractions either. The fact is: NO decimal, and no ordinary fraction, can be converted to a whole number. That's why we need them.