215 views
0 votes
0 votes

What is the output of following program?
main ( )
{
union a
  {
    int i;
    char ch[z];
  }
union a,u;
u∙i=256
  printf (%d%d%d,u∙i,u∙ch[0],u∙ch[1] ); 
}

  1.  255 1 0
  2.   256 0 1
    Explanation:
    In union all elements refer to the same slot of memory. Thus in ▁(union a) if 2 bytes say 4501 & 4502 are allocated to ▁(int i) then ch[0] refers to 4501 & ch[1], to 4502.
    image:n71.PNG
  3.  256 1 0
  4.  255 0 1

How are they deciding u.ch[0] = 0  or u.ch[1] =1 ????

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
2
Nishi Agarwal asked Mar 10, 2019
509 views
A(n){if(n<1) return (1);else return A(n-2)+B(n-1);}B(n){if(n<=1) return 1;else return B(n-1)+A(n-2);}
2 votes
2 votes
1 answer
3
0 votes
0 votes
0 answers
4