Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming. Due: By the end of your ab sesSIOn OBJECTIVES: bitwise operations main() function: Declare an int variable, name it number. 2. 1. Prompt

C programming. image text in transcribed
image text in transcribed
Due: By the end of your ab sesSIOn OBJECTIVES: bitwise operations main() function: Declare an int variable, name it number. 2. 1. 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. Display number to the screen - It will be a negative number. 6. Determine the rightmost bit in the number, display it to the screen (0 or 1): int maskRight- l:1/ 0000 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. Determine the third bit from the right in the number 7. . int mask3rd A/ 0000 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. . 8. Shift the number to the left by 2 bits -display the updated number to the screen (It will be multiplied by 2 twice). 9. Shift the updated number to the right 3 bits - display the outcome to the screen. 10. Add the rerun loop to the program -allowing the user rerun the program with different input numbers. (Hint: do-while loop)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions