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, 22.06.2019 13:30
1. technician a says horsepower information can be used by consumers to compare the power of different automobile engines. technician b says that manufacturers will often list the horsepower output of their engines in the online service information. who is right?
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. andre was recently hired by an organization to check for system vulnerabilities. he is supposed to exploit these vulnerabilities and create a report on the extent of damage to which the system was susceptible. what position does andre hold in this organization? a. information security analyst b. information assurance manager c. penetration tester d. network security engineer e. chief information security officer
Answers: 2
You know the right answer?
Objectives: number system, bitwise operations, masking. main() function: 1. declare an int variabl...
Questions
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Biology, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
English, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
English, 11.09.2020 21:01
question
History, 11.09.2020 21:01
question
Geography, 11.09.2020 21:01
question
Social Studies, 11.09.2020 21:01
question
Mathematics, 11.09.2020 21:01
question
English, 11.09.2020 21:01
Questions on the website: 13722359