Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ programming language Well be creating a small program that will display all the binary in an int. Well be manipulating the bits inside the

C++ programming language

Well be creating a small program that will display all the binary in an int. Well be manipulating the bits inside the integer and displaying them to the user. First, however, we should set up some global (gasp!) helper functions.

TurnOn This function should take in a number to determine which bit should be turned on (so a 3 would be bit 3, starting from the right). Simply make sure that the bit is turned on.

TurnOff Just like TurnOn, only the opposite. So nothing like it. This function will also take in a bit that it will change, and then turn it off using a combination of bitwise operators.

Toggle As in the previous two, this will take in a bit number and toggle it using the OR bitwise operator.

Negate Invert all the bits using the negate operator

Left and Right Shift- These two separate functions will left and right shift the number just once in the respective direction.

Main.cpp In the global space, declare an int that we will be manipulating using our functions. Then, down in main, make sure you display the bits of the integer, so a bunch of 0s. Under the right-most bit, display a carrot, or something to mark which bit youre looking at. Something like this:

Bits: 0000000000000000 ^

Allow the user to cycle through the bits using the left and right arrow keys. Once a bit has selected, allow the functions to change the bits. F1 will turn it on, F2 will toggle it, F3 will turn it off, F4 will negate the entire int, and left and right shift keys will, well, shift left and right.

Do not use std::bitset to display the bits. This will be a Thats it! Once you can comfortably destroy this poor number, consider displaying the actual number to the screen so you can see how the bits affect the whole decimal number.

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

2. To compare the costs of alternative training programs.

Answered: 1 week ago