
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
Edition 2ISBN: 978-0131409095
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
Edition 2ISBN: 978-0131409095 Exercise 3
Write a program that reads lines of input consisting of a bitwise operator (see Problem 1)- , |, ~, ^, , or -followed by integer operand(s) and then outputs the integer operands, the bitwise operator, and the result obtained by applying the operator to the operands. Display all numbers both in decimal form and in their 32-bit binary representation, using the printBinary() function from Problem 1. For example, the input
13 27 might produce the output
Applying the bitwise AND operator to the following 13 = 00000000000000000000000000001101 27 = 00000000000000000000000000011011produces 9 = 00000000000000000000000000001001 and the input
~ 1
produce the output
Applying the bitwise NOT operator ~ to the following 1 = 00000000000000000000000000000001produces -2 = 11111111111111111111111111111110
13 27 might produce the output
Applying the bitwise AND operator to the following 13 = 00000000000000000000000000001101 27 = 00000000000000000000000000011011produces 9 = 00000000000000000000000000001001 and the input
~ 1
produce the output
Applying the bitwise NOT operator ~ to the following 1 = 00000000000000000000000000000001produces -2 = 11111111111111111111111111111110
Explanation
Program Plan:
Main method:
• Declare t...
ADTs, Data Structures, and Problem Solving with C++ 2nd Edition by Larry Nyhoff
Why don’t you like this exercise?
Other Minimum 8 character and maximum 255 character
Character 255