Question: C++ please! Write a program to take a positive integer from 0 to 255 via cin and on the same line: 1) Print the number

C++ please!

Write a program to take a positive integer from 0 to 255 via cin and on the same line: 1) Print the number entered 2) Print out the binary representation 3) Print the ones complement of the number in binary The program should loop until a -1 is entered Example: Decimal 4 is 0100 in binary. Its ones complement is: 1011. Decimal 3 is 0011 in binary. Its ones complement is: 1100. You must calculate the initial binary value for each decimal number, not use a lookup table. You should test your program with the following inputs: (1) Decimal value = 13 (2) Decimal value = 27 (3) Decimal value = 0 (4) Decimal value = 255

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 Databases Questions!