Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in programming language C please Write a program called bitMath.c that asks the user for two 8-bit sequences that correspond to integers stored in the
in programming language C please
Write a program called bitMath.c that asks the user for two 8-bit sequences that correspond to integers stored in the two's compliment representation. It should then add the bit sequences together to produce a resulting bit sequence that is the sum of the two numbers. The program should display the bit sequences as well as their decimal value with output in the format shown in the following output (assu he program was run 8 times s ./bitMath Enter 1st -bit sequence : 00001D10 Enter 2nd 8-bit aequence: 00000111 00001010 (10) 00000111 (7 00010001 (17) atudent& CoMPBase:-$./bitMath Enter 1st 8-bit sequence: 11110110 11110110 (-10) 11101111 (-17) student& COMPBase: /bitHath Enzer lst 8-bit sequance: 10000 000 Enter 2nd-bit sequence : 0000U01 10000000 (-128) 00000001 (1 10000001 (-127) studentR COMPBase: /bitHath Ente 1 8-bit sequence : 0111DD11 Enter 2nd 8-bit sequence: 00111001 01110011 00111001 115) (57) OVERFLO DETECTED student8 COMPBase: s./bitMath Enter 1st 8-bit Enzer 2nd 8-bit sequonce: 10000001 sequence: 10000000 10000000 (-128 10000001 (-127) studont COMPBaso:-./bithath Ente1:@t 8-bitequence : 0001 1 1 Enter 2nd 8-bit sequence: 1001 Error: You must enter tuo vailia 8-bit atring sequencea student CoMPBasa:-$./bitMath Enter 1st 8-bit sequence: 11hh1139 Enter 2nd 8-bit sequence Exror: Bit sequence1 has non-binary characters kd232811 Enter 1st 8-bit sequence: 10011001 Enter 2nd B-bit sequence Error Bit sequence 2 has non-binary characters : 10k03r4s To write this code, it makes sense to have at least 4 functions: a main function, a function for flipping bits (for the negative numbers), a function for adding two bit sequences, and a function for converting a bit sequence to a decimal value. It would be good to follow the following steps to obtain your solution systematically. Don't move on until you get each step working 1. Get the input from the user 2. Ensure that each input sequence is 8 characters long 3. Check to ensure that there are only 1's and O's in the bit sequence 4. Display the input sequences along with their decimal equivalents (test only positive numbers) 5. Write the function to add the bit sequences and produce the result (test only positive numbers) 6. Write the function to flip the bits of a sequence 7. Adjust your code to work for negative numbers 8. Add the overflow checking 9. Test thoroughly Test your code thoroughly and hand in the output from your test cases in a file called output.txt. You will be marked according to the thoroughness of your test cases. Think of the tricky test cases and boundary test cases. If you miss some "obvious" boundary test cases, you will lose marks... so test more than you need if you are not certain
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