Question: Your program should have test cases in the main function. Note: Do not use arrays to store the binary representation of the input and /
Your program should have test cases in the main function.
Note: Do not use arrays to store the binary representation of the input andor output
numbers. Arrays require extra memory space which can be avoided by using bitwise
operations on variables directly. Since this is a bit manipulation exercise, using arrays is
not allowed. Using arrays is inefficient for this problem and also makes the problem
trivial.
Combine bits from two integers and Assume both are unsigned integers data type is
unsigned int The function should return an unsigned int as well as an answer.
Example:
in hex and in binary
in hex and in binary
is the answer after combining bits from and
The figure below also shows the how bits from and are combined to get bits in
combine combine in decimal.
Test case: The inputs and should be less than
and
and
Hint: Looking at the bits at different bit positions, you can see that the bits are getting shifted in order to combine them.
Unsigned number example:
int main
unsigned int ;
printfa u
a;
printfEnter b ln;
unsigned int ;
scanfu &b;
printfYou entered u In b;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
