/* C program to swap bytes/words of integer number.*/
#include <stdio.h>
int main()
{
unsigned int data = 0x1234;
printf("\ndata before swapping : %04X", data);
data = ((data << 8) & 0xff00) | ((data >> 8) & 0x00ff);
printf("\ndata after swapping : %04X", data);
return 0;
}
data before swapping : 1234
data after swapping : 3412
Swapping two Bytes/Words using C program
need an explanation for this answer? contact us directly to get an explanation for this answer