// Decimal To Hexidecimal
// By DreamVB 23:57 18/10/2016

#include <iostream>

using namespace std;
using std::cout;
using std::endl;

string BaseConvert(int decimal, int radix){
	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 += floor(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;

	cout << "Enter a decimal number : ";
	cin >> dec;

	cout << "The hexidecimal value of " << dec << " is " << BaseConvert(dec, 16).c_str() << endl;

	system("pause");
	return 0;
}