Write a C/C++ function that will return a word consisting of
the
most significant byte of x, and the remaining bytes of y. For
operands x =
0x89ABCDEF and y = 0x76543210, this would give 0x89543210. Data
type int is w bits long. The code should work as long as w is
a multiple of 8. You can use the expression sizeof(int)<<3 to
compute w.
#include <iostream>
using namespace std;
int main() {
int x = 0x89ABCDEF;
int y = 0x76543210;
// this would give 0x89543210.
x = x >> 24;
x = x << 24;
y = y << 8;
y = y >> 8;
cout <<"0x" <<hex << (x | y) <<endl;
}
=======================================================
SEE OUTPUT
Thanks, PLEASE COMMENT if there is any concern.
Get Answers For Free
Most questions answered within 1 hours.