Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/*function lezbep converts a little endian int and return it as a big endian int. The code does this using pointers. No built-in or library

image text in transcribed

/*function lezbep converts a little endian int and return it as a big endian int. The code does this using pointers. No built-in or library conversion functions are used. Assume that the address of int d is 0x10000, and the address of int bed is Ox11000 for the purpose of filling in the blanks*/ int le2bep(int x){ int d = x; //d = Ox_ char *dptr=&d; //dptr = 0x int bed; char *bedptr = &bed; 1/bedptr = 0x *(bedptr + 3) = * dptr; //*(bedptr + 3) = 0x *(bedptr + 2) = *(dptr + 1); 1/*(bedptr + 2) = 0x *(bedptr + 1) = *(dptr + 2); //*(bedptr + 1) = 0x *bedptr = *(dptr + 3); // *bedptr = Ox return bed; //bed = Ox } int main() unsigned char h = 175; unsigned i = 0x0000ffff; unsigned hrslt; int irslt; hrslt = dec2bin(h); printf("calculated hex value of %d is: Ox%x ", h, hrslt); printf("actual hex value of %d is: Ox%x ", h,h); irslt = bin2dec(i); printf("calculated decimal value of 0x%x is: %d ",i,irslt); printf("actual decimal value of 0x%x is: %d ",1,1) printranges(); chkendian(); unsigned le = 0x01234567; printf("Using logical ops: "); printf("Little Endian = 0x%x,Big Endian = 0x%x ", le,le2be(le)); printf("Using pointers: "); printf("Little Endian = 0x%x,Big Endian = 0x%x ",le, lezbep(le)); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions