#include <stdio.h>
void print_binary(unsigned int number);
int main() {
printf("Swap integers!\n");
unsigned int n;
printf("Enter a number\n");
scanf("%x",&n);
printf("The Entered number is %x \n",n);
printf("n & 0x000000ff %x\n",(n & 0x000000ff));
printf("n & 0x0000ff00 %x\n",(n & 0x0000ff00));
printf("n & 0x00ff0000 %x\n",(n & 0x00ff0000));
printf("n & 0xff000000 %x\n",(n & 0xff000000));
printf("((n & 0x000000ff) << 24) %x\n",((n & 0x000000ff) << 24));
printf("((n & 0x000000ff) << 8) %x\n",((n & 0x000000ff) << 8));
//Swap the bytes
n = (((n & 0x000000ff) << 24) | ((n & 0x0000ff00) << 8) | ((n & 0x00ff0000) >> 8 ) | ((n & 0xff000000) >> 24));
printf("The Entered number is %x ",n);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: