Write C Function Would Return Least Significant Byte Significant Byte Passed Int Q37090747

write a Cfunction that would return the least significant byte and the mostsignificant byte of a passed-in int


Solution


#include <stdio.h>void least_most(int n, int *least, int *most) { *most = (n >> 24) & 0xFF; *least = n & 0xFF;}int main() { int n = 0x1D0000A7; int least, most; least_most(n, &least, &most); printf(“Most significant byte is 0x%xn”, most); printf(“Least significant byte is 0x%xn”, least); return 0;}

Most significant byte is 0x1d Least significant bvte is Oxa7 Process finished with exit code 0

Please let me know if you have any doubts Please upvote this answer. Thanks!!

Most

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.