Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a function that will out put like this in C not C++ Thank you . replace.c This code will contain a single function

image text in transcribedimage text in transcribed

Please write a function that will out put like this in C not C++ Thank you

. 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. One team member, and only one team member, will be responsible for the source code in this file in GitLab, though collaboration with other group members may be done if needed. Enter a positive integer less than 2 billion: 0 Enter a positive integer less than 2 billion: 2000000000 Enter a positive integer less than 2 billion: 7 Enter a positive integer mask up to 3 billion: 0 Enter a positive integer mask up to 3 billion: 3000000000 Enter a positive integer mask up to 3 billion: 8 Enter the bit replacement position from mask (0-indexed): -1 Enter the bit replacement position from mask (0-indexed): 32 Enter the bit replacement position from mask (0-indexed) : 3 New integer with bit 3 from mask 8 is 15

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions