I need to implement but I am not sure how can I as I am completely new into this. A function called get_values that has the prototype:
void get_values(unsigned int value, unsigned int *p_lsb, unsigned int *p_msb,
unsigned int *p_combined)
The function computes the least significant byte and the most significant byte of the value parameter. In addition, both values are combined. For this problem:
a. You may not use any loop constructs. b. You may not use the multiplication operator (* or *=). c. Your code must work for unsigned integers of any size (4 bytes, 8 bytes, etc.). d. To combine the values, append the least significant byte to the most significant one. e. Your implementation should be efficient.
The following driver (and associated output) provides an example of using the function you are expected to write. Notice that in this example an unsigned int is 4 bytes, but your function needs to work with an unsigned int of any size.
Driver
int main() {
unsigned int value = 0xabcdfaec, lsb, msb, combined;
get_values(value, &lsb, &msb, &combined);
printf("Value: %x, lsb: %x, msb: %x, combined: %x\n", value, lsb, msb, combined);
return 0;
}
Output
Value: abcdfaec, lsb: ec, msb: ab, combined: abec