Solved

# Bitwise opperators

Posted on 2003-02-20

Ok i have a project due and dont' know how to start it, so here is the question:

Write a function that returns x with the n bits that begin at postition p set to the rightmost n bits of y, leaving the other bits unchanged. Do not implement wrap-around. The function prototype should be as follows:

unsigned long setbits(unsigned longx, int p, int n, unsigned long y);

Your test driver shall prompt the user for n, p, and y. Assume that y is being entered in HEX and use the appropriate scanf argument. Then call the function and save the result as the operand and display the changed operand in 8 digit HEX format.