Home / Expert Answers / Computer Science / write-a-program-that-reads-in-two-hexadecimal-numbers-by-using-the-cin-gt-gt-command-and-prints-pa820

(Solved): Write a program that reads in two hexadecimal numbers by using the cin >> command, and prints ...



Write a program that reads in two hexadecimal numbers by using the cin >> command, and prints out the sum of the two numbers in hexadecimal. For example, 45AF 12B3 your program will output (if you output the result in decimal): The decimal sum of 45AF and 12B3 is 22626. To solve this problem: a) read the hexadecimal numbers as character arrays b) convert the character arrays to numbers (by calling a function that takes the character array as a parameter and returns an integer) c) add the numbers to get a decimal sum !!! Please do C++. The code that is given is:

#include <iostream>
#include <fstream>
using namespace std;
int addTwoHex(string input1, string input2);
string decToHex( int result);
int main() {
   
   //read  2 hex numbers
   // pass them to a addTwoHex function that should return their decimal sum
   /* Type your code here. */

   
   

   return 0;
}
 



We have an Answer from Expert

View Expert Answer

Expert Answer


Code: #include #include using namespace std; // declare function prototypes int addTwoHex(string input1, string input2); string decToHex(int result); // I'm adding another helper function to convert hex to decimal int hexToDec
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe