Preview:
#include <iostream>
#include <string>
using namespace std;
using std::string;
const string hexdigits = "0123456789ABCDEF"; // possible hex digits


int main()
{
	
	cout << "Enter a series of numbers between 0 and 15"
		<< " separated by spaces. Hit ENTER when finished: "
		<< endl;
	string result = ""; // will hold the resulting hexify’d string
	unsigned int n; // hold numbers from the input
	

	while (cin >> n )
	{
		if (n < 16) // ignore invalid input
			result += hexdigits[n]; // fetch the indicated hex digit
		else if (n == 17)
			break;
	}

	cout << "Your hex number is: " << result << endl;

	return 0;
}

downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter