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 and/or 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 x and y. Assume both are unsigned integers (data type is
unsigned int x,y). The C function should return an unsigned int as well as an answer.
Example:
x=0x8 in hex and x=1000 in binary
y=0x6 in hex and x=0110 in binary
z is the answer after combining bits from x and y.
The figure below also shows the how bits from x and y are combined to get bits in z.
Z= combine (x,y)= combine (8,6)=01101000=104 in decimal.
Test case: The inputs x and y should be less than 65,535.
x=101 and y=123
x=99 and y=71
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 a=63;
printf(a =%u
, a);
printf(Enter b ln);
unsigned int b;
scanf("%u", &b);
printf(You entered %u In, b);
}
 Your program should have test cases in the main function. Note:

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!