Question: C CODE ONLY PLEASE Replace.c This code will contain a single function that accepts a single positive integer less than two billion (and the include

C CODE ONLY PLEASE

Replace.c

This code will contain a single function that accepts a single positive integer less than two billion (and the include directive to your header file) to perform the following functionality:

(1) prompt for and read in a positive integer mask less than three billion and continue to prompt for and read in the positive integer mask until the user enters and acceptable value (no error message is needed here),

(2) prompt for and read in the bit replacement position from the mask and continue to prompt for and read in the bit replacement position from the mask until the user enters an acceptable value (no error message is needed here, but note that since we are working with 32-bit unsigned integers, the value should be between 0 and 31, inclusively), and finally

(3) replace the single bit in the original positive integer less than two billion passed to the function with the single bit from the positive integer mask specified by the user (i.e., in the bit replacement position from the mask). For example, if the user initially enters 7 (in binary, 00...00111) as the positive integer less than two billion, then enters 8 (in binary, 00...01000) for the positive integer mask and 3 for the bit replacement position, you will replace the third bit from the positive integer 7 (a 0) with the third bit from the positive integer mask (a 1), resulting in the new value 15 (in binary, 00...01111). The operations to replace the bit must be done using bitwise operators. Additionally, no loops may be used (except in error checking when prompting for and reading in the positive integer mask and bit replacement position from the mask) to achieve this functionality.

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 Databases Questions!