Question: Write a program to set bits within a range of bits to 1 s for an int variable num. Read in num, start bit, and

Write a program to set bits within a range of bits to 1s for an int variable num. Read in num, start bit, and end bit using "scanf". Display num in binary form before and after setting the bits.
Output example:
Enter a number: 478
00000000000000000000000111011110
Enter the start bit (0-31): 20
Enter the end bit (0-31): 18
The new number: 1835486
00000000000111000000000111011110

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!