Thursday 28 March 2019

UGC NET Computer Science July 2018 - II | Question 4

Question 4
4. 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 <stdio.h>
#include <stdlib.h>
/* 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 */

Options:
  1. (1) 5, 2, 1282
  2. (2) 5, 2, 52
  3. (3) 5, 2, 25
  4. (4) 5, 2, 517
Answer : (4) 5, 2, 517


Explanation Question 4

A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose.


PreviousNext
UGC-NET CS 2018 July - II Question 3UGC NET CS 2018 July - II Question 5

No comments:

Post a Comment

UGC NET Computer Science December 2019 | Question 16

Question 16 In a certain coding language. 'AEIOU' is written as 'TNHDZ'. Using the same coding language. 'BFJPV' wil...

Popular Posts