# Base10 Convertor

Email
 Submitted on: 10/18/2016 11:16:32 PM By: Ben128 Level: Beginner User Rating: Unrated Compatibility: C++ (general), Microsoft Visual C++ Views: 3635

A small project that converts decimal numbers to 6 different bases. Hope it maybe usfull.

code:
Can't Copy and Paste this?
 ``` //************************************** // Name: Base10 Convertor // Description:A small project that converts decimal numbers to 6 different bases. Hope it maybe usfull. // By: Ben128 //************************************** // Base convert // By DreamVB 00:01 19/10/2016 #include using namespace std; using std::cout; using std::endl; string BaseConvert(int decimal, int radix){ //Base convertor char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; string Ret = ""; int n = decimal; int base = 0; while (n >= radix){ base = (n % radix); n /= radix; Ret += hexmap[base]; } //Add last hexmap char Ret += hexmap[n]; //Reverse string std::reverse(Ret.begin(), Ret.end()); return Ret; } int main(int argc, char *argv[]){ int dec = 0; system("title Base10 Converting"); cout << "Enter a decimal number : "; cin >> dec; cout << endl; cout << "Binary : " << BaseConvert(dec, 2).c_str() << endl; cout << "Ternary : " << BaseConvert(dec, 3).c_str() << endl; cout << "Quinary : " << BaseConvert(dec, 5).c_str() << endl; cout << "Octonary: " << BaseConvert(dec, 8).c_str() << endl; cout << "Decimal : " << BaseConvert(dec, 10).c_str() << endl; cout << "Hexidecimal : " << BaseConvert(dec, 16).c_str() << endl; system("pause"); return 0; }```

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)