Question: Write a program in c + + that takes in a positive integer from 0 to 6 4 5 3 5 as input. This unsigned

Write a program in c++ that takes in a positive integer from 0 to 64535 as input. This unsigned integer decimal is then displayed as 16 bits one bit at a time. Your output will be a sequence of sixteen 0s and 1s that are equivalent to the decimal value.
Implement the concept using a loop of processing the binary places one at a time from left to right.
At the current binary place, decide whether the current binary place fits into the decimal number. If it does then a 1 bit goes into the current binary place and the decimal number is reduced by the current binary place value. If it does not than a 0 bit goes into the current binary place.
Ex: If the input is:
34561
the output line is:
1000011100000001
Notice that there is a space character between every four bits in the binary number.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!