Question 5119 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023
Question 5121 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023
Question 5119 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023
Question 5121 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023

Question 5120 – UGC NET CS 2018 JUNE Paper-2

What is the output of the following ‘C’ program ? (Assuming little – endian representation of multi-byte data in which Least Significant Byte (LSB) is stored at the lowest memory address.)
#include
#include
/* Assume short int occupies two bytes of storage */
int main ( )
{
union saving
{
short int one;
char two[2];
};
union saving m;
m.two [0] = 5;
m.two [1] = 2;
printf(’’%d, %d, %d\n”, m.two [0], m.two [1], m.one);
}/* end of main */

Correct Answer: D

Question 4 Explanation: 
● m.two[0] holds the value 5 and m.two[1] holds the value 2 So it will print 5 and 2 values.
● Size of the short integer is 2 bytes. Saving is union variable, we will access one variable at time and only one memory location is shared among all the members.So the two values 5 and 2 (two bytes of the data) will store in little endian format in the variable
m.one.
● Endianness is the sequential order in which bytes are arranged into larger numerical values when stored in memory or when transmitted over digital links.
● In big-endian format, whenever addressing memory or sending/storing words bytewise, the most significant byte—the byte containing the most significant bit—is stored first (has the lowest address) or sent first, then the following bytes are stored or sent in decreasing significance order,
● Little-endian format reverses this order: the sequence addresses/sends/stores the least significant byte first (lowest address) and the most significant byte last (highest address).
● First 5 will store in the lowest address and 2 will store next highest address.
● So the binary representation 5 and 2 in little endian format is
00000010 00000101
The binary number of the above is 517
A
5, 2, 1282
B
5, 2, 52
C
5, 2, 25
D
5, 2, 517
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!