Question
IN C++ PLEASE: Lab: Hexadecimal addition Part 1: Please include an alogorithm on how you would write this program Write a program that reads in
IN C++ PLEASE:
Lab: Hexadecimal addition
Part 1:
Please include an alogorithm on how you would write this program
Write a program that reads in two hexadecimal numbers from a file, hex.txt, and prints out the sum of the two numbers in hexadecimal.
From Wikipedia: In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 09 to represent values zero to nine, and A, B, C, D, E, F (or alternatively af) to represent values ten to fifteen. For example, the hexadecimal number 2AF3 is equal, in decimal, to:
(2 163) + (10 162) + (15 161) + (3 160), or 10,995.
For example, if the file contains:
45AF
12B3
...your program will 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
d) Convert the sum to hexadecimal (by calling a function that fills a character array)
Part 2:
Assume that your file has an unknown number of hexadecimals.
Modify / Enhance /Change your program so that it prints the sum of all the numbers in the file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started