Programming Assignment
Write a program that will read a series of lines from an input file named hw8in.txt. Each line will contain 3 values:
A whole number
A numerator
A denominator
Collectively, these 3 values represent a floating point number. For example, a possible line of input might be:
3 3 4
This will become: 3.0 + 3.0 / 4.0 or 3.75
Your program will store this value in a float (Do NOT use double) and will display to the console, both its float and floating point binary values. Again using the above float from the input file, the output would be:
Floating point format of 3.750000000000000:
0 10000000 11100000000000000000000
Your program must create the same output as shown in the sample run that is included below. This includes breaking the 32 bits into 3 separate fields (sign, exponent, and fraction).
NOTE: Due to the input format of whole, numerator, denominator, you will need to use 0 1 for the last 2 digits if there is no fractional portion to the entire value to be evaluated. E.g. 5 0 1 will evaluate to 5.0.
Design your own input file (Hw8in.txt) and include as many variations of input as needed to fully test your program.
Write the entire program in one .c file (Hw8.c). Organize your solution into a sensible set of functions. As always, turning in code you may find on the internet is not acceptable. The goal of the assignment is for you to practice manipulating bits.
The float data type of C usually requires 32 bits (or 4 bytes). To ensure this is true for your machine, try this: printf("float size in bytes: %d", sizeof(float)); If the value printed out is not 4, please talk to me about how to do the assignment.
Attachment:- Input-file.rar