In this introductory minor assignment, you will write a complete C program that will prompt for and accept two 4-digit hexadecimal numbers and then combine them i.e., not add them) into a single 32-bit number and print out the results.
1. Prompt for and read in two 4-digit hexadecimal numbers. You may assume that the user enters a hexadecimal number, though it may be out of range. A valid hexadecimal range is considered to be 0000 to FFFF. If out of range, you will continually repeat this process until two valid 4-digit hexadecimal numbers are entered.
Note that you may read in these two 4-digit hexadecimal numbers any way you wish i.e., a hexadecimal number or a C-string that you convert to a hexadecimal number), but you must ultimately treat these as individual hexadecimal numbers.
2. You will print out the decimal representation for each of these hexadecimal numbers.
3. You will concatenate the two 4-digit hexadecimal numbers as follows into a single 8-digit hexadecimal number, where the first hexadecimal number will be in the 4 least significant digits while the second hexadecimal number will be in the 4 most significant digits.
Note that this operation to concatenate must be done numerically and not simply concatenated as a string. Ideally, you would use bitwise operators to do this, but either way, you must do so while treating these as hexadecimal numbers.
4. You will print out the concatenated hexadecimal number as well as its decimal representation.
As a hint, you may want to perform bitwise operations to accomplish this, but also pay attention to the data types used for these numbers.
Although not required, you may find Chapter 2 on Bits, Bytes, and Data Types in the System Programming with C and Unix optional reference textbook by Adam Hoover to be helpful.
SAMPLE OUTPUT
$ ./a.out
Enter a 4-digit hexadecimal number (e.g., "af43"): 1FFFF
1ffff is out of range. Please try again...
Enter a 4-digit hexadecimal number (e.g., "af43"): -123
fffffedd is out of range. Please try again...
Enter a 4-digit hexadecimal number (e.g., "af43"): 1234
Your number in decimal is: 4660
Enter another 4-digit hexadecimal number (e.g., "af43"): abcd
Your number in decimal is: 43981
Merging 0x1234 and Oxabcd results in Oxabcd1234 or 2882343476 in decimal
$ ./a.out
Enter a 4-digit hexadecimal number (e.g., "af43"): af43
Your number in decimal is: 44867
Enter another 4-digit hexadecimal number (e.g., "af43"): 9ffe
Your number in decimal is: 40958
Merging 0xaf43 and 0xffe results in Ox9ffeaf43 or 2684268355 in decimal