I need to write a program that reads in two hexadecimal numbers, converts them to decimal form, and prints out the sum of the two numbers in decimal. This is as far as I've gotten, I can't seem to get the right values to add up.
#include <iostream>
#include <iomanip>
using namespace std;
void Hex_to_Dec(char &, char &);
int main()
{
char hex1;
char hex2;
cout << " Please enter a hexadecimal number: " << endl;
cin >> hex1;
cout << " Please enter another hexadecimal value: " << endl;
cin >> hex2;
Hex_to_Dec(hex1, hex2);
cout << "The decimal sum of" << hex1 << " and " << hex2 << " is " << hex1 + hex2 << endl;
return 0;
}
void Hex_to_Dec(char & hex1, char & hex2)
{
std::cin >> std::hex >> hex1;
std::cout << hex1 << std::endl;
std::cin >> std::hex >> hex2;
std::cout << hex2 << std::endl;
}