subject

Objectives: number system, bitwise operations, masking. main() function: 1. declare an int variable, name it number. 2. prompt the user to enter a whole number – read it into the variable. • validate the range in a loop. valid range is 20 to 200 both inclusive 3. display the number to the screen (base 10) 4. display the number in hexadecimal (use %x) 5. determine the rightmost bit in the number, display it to the screen (0 or 1): • int maskright = 1; // 0001 • do a bitwise & between the number and the maskright. if it is equal to 0, the rightmost bit is 0, otherwise, it is 1. 6. determine the third bit from the right in the number • int mask3rd = 4; // 0100 • do a bitwise & between the number and mask3rd – if it is equal to 0 the 3rd bit in the number is 0, otherwise it is 1. 7. display the number in 16 bit binary as follows: • define a mask = 1 < < 15; // 1000• write a loop that iterates 16 times. in each cycle: i. do a bitwise & between the mask and the number (in an if statement). ii. display the corresponding bit (0 or 1) iii. shift the mask to the right one bit for the next cycle. iv. if the loop variable is divisible by 4 print a space " ". 8. shift the number to the left by 2 bits – display the updated number to the screen (it will be multiplied by 2 twice).

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:10
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
Pressing the backspace key deletes the text to the of the insertion point. the left or the right?
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
What are some examples of what can be changed through options available in the font dialog box? check all that apply. font family italicizing bolding pasting drop shadow cutting character spacing special symbols
Answers: 2
question
Computers and Technology, 24.06.2019 21:30
The hybrid uses 144 to 158 volt batteries.
Answers: 1
You know the right answer?
Objectives: number system, bitwise operations, masking. main() function: 1. declare an int variabl...
Questions
Questions on the website: 13722361