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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:30, brin1021
Jessie has received a contract to build a real-time application for a baker. however, the baker doesn't want to invest too much money. his only requirement is that he wants the customers to know which cupcakes are available at what time and in what quantity. so his core requirement is that the details of product should be in real time. what platform can jessie use to develop this application?
Answers: 1
image
Computers and Technology, 23.06.2019 04:31, mjweed3381
Cloud computing service providers manage different computing resources based on the services they offer. which resources do iaas and paas providers not manage? iaas providers do not manage the for the client, whereas paas providers usually do not manage the for their clients. iaas- storage server operating system network paas- applications interafce storage vertualiation
Answers: 2
image
Computers and Technology, 23.06.2019 15:30, taapeters
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, cheycheybabygirl01
How can the temperature of a room be raised by 5degreesf?
Answers: 1
You know the right answer?
Objectives: number system, bitwise operations, masking. main() function: 1. declare an int variabl...

Questions in other subjects:

Konu
Mathematics, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01
Konu
English, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01
Konu
Chemistry, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01
Konu
Mathematics, 13.09.2020 21:01