Question: C PROGRAM PLZ GIVE CORRECT OUTPUT DO NOT GIVE WRONG OUTPUT 1 - WAP to convert Little Endian data to Big Endian Description: Check the
C PROGRAM PLZ GIVE CORRECT OUTPUT DO NOT GIVE WRONG OUTPUT
1 - WAP to convert Little Endian data to Big Endian
Description:
Check the memory assigning order of variables for checking whether little endian or big endian machine
Little Endian:
-------------- Say int i = 10; gets stored in memory at 1000 1001 1002 1003 where 1000 contains LSB of i and 1003 contains MSB of i char *ptr = &i; the ptr will now contain 1000
Big Endian: ----------- Say int i = 10; gets stored in memory at 1000 1001 1002 1003 where 1000 contains MSB of i and 1003 contains LSB of i char *ptr = &i; the ptr will now contain 1000
Read 2 byte or 4 byte data according to given size(short or Int). Swap the bytes and convert the given data to Big Endian
Pr-requisites:
Pointers
Objective: -
To understand the concept of
Big Endian and Little Endian representation
Inputs: -
Read size of the datatype(short or Int) and an number which has to be convrted
Sample execution: - Test Case 1: Enter the size: 2 Enter any number in Hexadecimal: ABCD After conversion CDAB Test Case 2: Enter the size: 4 Enter any number in Hexadecimal: 12345678 After conversion 78563412
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
