this code needs to take in an unsigned int. can you add it please. /** Define Byte number*/#define B0 0#define B1 1#define B2 2#define B3 3int swap(int number) {/** assign number address to char...


this code needs to take in an unsigned int. can you add it please.


#include<stdio.h><br>/** Define Byte number*/<br>#define B0 0<br>#define B1 1<br>#define B2 2<br>#define B3 3<br>int swap(int number) {<br>/** assign number address to char pointer, sc<br>char *num = (char*) (&number);<br>/** Swap byte B0 and B4 data by using bitwise<br>num[ B0] = num[B0] ^ num[ B3];<br>num[ B3] = num[ B0]<br>num[ B0] = num[B0]<br>num[B3];<br>num[ B3];<br>/** Swap byte B1 and B2 data by using bitwise<br>num[ B1] = num[B1] num[ B2 ];<br>num[B2] = num[B1] ^ num[ B2 ];<br>num[ B1] = num[B1]<br>num[ B2];<br>/** return new number after swapping of requi<br>return number;<br>}<br>int main() {<br>int num;<br>int num after_endian_swap;<br>printf(= 1 and <= 42="" scanf="" ("&d",="" &num);="" num_after_endian_swap="swap(num);" printf(="" "endian="" swap="" of="" %d="" gives="" %d\n",="" num,="" n="" return="" 0;="" "/="">
Extracted text: #include /** Define Byte number*/ #define B0 0 #define B1 1 #define B2 2 #define B3 3 int swap(int number) { /** assign number address to char pointer, sc char *num = (char*) (&number); /** Swap byte B0 and B4 data by using bitwise num[ B0] = num[B0] ^ num[ B3]; num[ B3] = num[ B0] num[ B0] = num[B0] num[B3]; num[ B3]; /** Swap byte B1 and B2 data by using bitwise num[ B1] = num[B1] num[ B2 ]; num[B2] = num[B1] ^ num[ B2 ]; num[ B1] = num[B1] num[ B2]; /** return new number after swapping of requi return number; } int main() { int num; int num after_endian_swap; printf("Enter a 32-bit number (>= 1 and <= 42="" scanf="" ("&d",="" &num);="" num_after_endian_swap="swap(num);" printf(="" "endian="" swap="" of="" %d="" gives="" %d\n",="" num,="" n="" return="">

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here