Sail E0 Webinar
Question


What is the output of the program?


#include<stdio.h>
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0] = 3;
u.ch[1] = 2;
printf("%d, %d, %d\n",u.ch[0], u.ch[1], u.1);
return 0;
}
Options:
A .  3, 2, 515
B .  515, 2, 3
C .  3, 2, 5
D .  None of these
Answer: Option A

printf("%d, %d, %d`setminus`n", u.ch[0], u.ch[1], u.i); It prints the value of u.ch[0] = 3, 

u.ch[1] = 2 and it prints the value of u.i means the value of entire union size.

What Is The Output Of The Program?#include<stdio.h>int...

So the output is 3, 2, 515



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers