Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(PROGRAM THIS IN C, NOT C++) Write a program which can accept binary numbers and certain operations to calculate the results of those operations. The

(PROGRAM THIS IN C, NOT C++)

Write a program which can accept binary numbers and certain operations to calculate the results of those operations. The user should see something like:

Enter a 16 bit unsigned binary number:

Enter operator (+, -, *, %, /, <<, >>, |, &, ^, E)

Enter a 16 bit unsigned binary number:

The answer is: (note: the answer should be displayed in both binary and decimal)

Enter operator (+, -, *, %, /, <<, >>, |, &, ^, E)

Enter a 16 bit unsigned binary number:

The answer is: (note: this should perform the operation on the previous answer and the newly entered number)

The program should continue in this manner, until E is entered as the operator. When E is entered, the program should terminate.

Hints: partition up the problem. Create subroutines to:

Accept input from the user and verify that they have entered a 16 bit binary number (note: youll need to handle binary numbers as strings)

Convert a string holding a binary number to an unsigned integer

Convert an unsigned integer to a string holding a binary representation of that number

Accept two numbers and an operator, perform the noted operation (hint: only capture the first < from << or > from >>, doing so will allow you to handle the operator as a simple character)

Hint #2: use fgets and sscanf to take user input. scanf alone will be tough to get correct.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

What secures mortgage bonds and equipment trust certificates?

Answered: 1 week ago

Question

How do cultural norms affect our behavior?

Answered: 1 week ago