Programming Assignment
Write a C program to add two hexadecimal numbers. The input data contains an even number of hexadecimal digit strings with maximum 64 bits and no leading zeros. The last two numerals are "0 0". Repeat the additon operation until both input hexadecimal numbers are 0's. In each iteration, the program will read two hexadecimal digit strings, n1 and n2, and add these two hexadecimal numbers with the result sum. In the output, print n1, n2, and sum aligning to the right with a "+" sign before n2 and a separated line below n2. Print "n1 + n2 = sum" in decimal. If the result exceeds 64 bits, print an overflow message. Do not compute the sum using decimal addition.
Sample input (hexadecimal_addition.txt):
1 FFFF
C9AE0232 5F1300033
3DBCE123E EAD2222
2873383898 D93E8C2FA3C
5555555555555555
AAAAAAAAAAAAAAAA
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
0 0
Sample output:
Write a C program to multiply two hexadecimal numbers. The input data contains an even number of hexadecimal digit strings with maximum 32 bits and no leading zeros. The last two numerals are "0 0". Repeat the multiplication operation until both input binary numbers are 0's. In each iteration, the program will read two hexadecimal digit strings, n1 and n2, and multiply these two hexadecimal numbers with the result product of maximum 64 bits. Note that the length of product could be the total length of n1 and n2. Hence, no overflow will occur. In the output, print n1, n2, and product aligning to the right with a "*" sign at the left-most character in the output line of n2 and a separated line below n2. Print "n1 * n2 = product" in decimal. Do not compute the sum using decimal multiplication.
Sample input (hexadecimal_multiplication.txt):
1 FFFF
34A C51
C9A32 5F0033
3DB3E21
EAD22
55555555 AAAAAAAA
FFFFFFFF FFFFFFFF
0 0
Sample output:
In this assignment, you must submit two source code files assignment5_dxxxxxxx_1.c (40%, for hexadecimal addition) and assignment5_dxxxxxxx_2.c (40%, for hexadecimal multiplication) and one report file to explain how you solve the two problems and write the programs assignment5_dxxxxxxx.pdf (20%), where dxxxxxxx is your student ID.