recategorized by
5,739 views
0 0 votes

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 */
  1. 5, 2, 1282
  2. 5, 2, 52
  3. 5, 2, 25
  4. 5, 2, 517

2 Answers

1 1 vote
Answer (4)
0 0 votes
Binary of 2: 00000010

Binary of 5: 00000101

so it stores in little endien so MSB+LSB

where MSB=2

LSB=5

so answer is 0000001000000101 : 517
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.9k
1.9k views
Pooja Khatri asked Jul 13, 2018
1,858 views
Which of the following statements is/are true?P: C programming language has a weak type system with static types.Q: Java programming language has a string type system wit...
79 79 votes
4 answers 4 answers
31.5k
31.5k views
Kathleen asked Sep 14, 2014
31,450 views
Consider the following C declaration:struct { short x[5]; union { float y; long z; } u; )t;Assume that the objects of the type short, float and long occupy $2$ bytes, $4$...
1 1 vote
2 2 answers
3.4k
3.4k views
Pooja Khatri asked Jul 13, 2018
3,423 views
The definitions in an XML document are said to be ______ when the tagging system ans definitions in the DTD are all in compliancewell-formedreasonablevalidlogical
1 1 vote
1 1 answer
4.5k
4.5k views
Pooja Khatri asked Jul 13, 2018
4,487 views
Consider the JavaScript Code:var y=”12” function f() { var y=”6”; alert (this.y); function g() {alert (y); } g(); } f();If $M$ is the number of alert dialog boxes generat...