Q3. What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)
Q4. What type of data is holded by variable u int in the following C code?
Q5. Members of a union are accessed as________________
Q6. In the following C code, we can access the 1st character of the string sval by using _______
Q7. What will be the output of the following C code (Assuming size of int and float is 4)?
Q8. What will be the output of the following C code?
Q9. What will be the output of the following C code?
Q10. What will be the output of the following C code?
#includeunion uTemp { double a; int b[10]; char c; }u;
- 4
- 8
- 40
- 80
Answer:- (A).
Explanations :none.
Explanations :none.
#includeunion u_tag { int ival; float fval; char *sval; } u;
- Will be large enough to hold the largest of the three types;
- Will be large enough to hold the smallest of the three types;
- Will be large enough to hold the all of the three types;
- None of the mentioned
Answer:- (A).
Explanations :none.
Explanations :none.
- union-name.member
- union-pointer->member
- both union-name.member & union-pointer->member
- none of the mentioned
Answer:- (C).
Explanations :none
Explanations :none
#includestruct { char *name; union { char *sval; } u; } symtab[10];
- *symtab[i].u.sval
- symtab[i].u.sval[0].
- You cannot have union inside structure
- Both *symtab[i].u.sval & symtab[i].u.sval[0].
Answer:- (D).
Explanations :none
Explanations :none
#includeunion { int ival; float fval; } u; void main() { printf("%d", sizeof(u)); }
- 16
- 8
- 8
- 32
Answer:- (C).
Explanations :none.
Explanations :none.
#includeunion stu { int ival; float fval; }; void main() { union stu r; r.ival = 5; printf("%d", r.ival); }
- 9
- Compile time error
- 16
- 5
Answer:- (D).
Explanations :none.
Explanations :none.
#includeunion { int x; char y; }p; int main() { p.x = 10; printf("%d\n", sizeof(p)); }
- Compile time error
- sizeof(int) + sizeof(char)
- Depends on the compiler
- sizeof(int)
Answer:- (D).
Explanations :none.
Explanations :none.
#includeunion { int x; char y; }p; int main() { p.y = 60; printf("%d\n", sizeof(p)); } }
- Compile time error
- sizeof(int) + sizeof(char)
- Depends on the compiler
- sizeof(char)
Answer:- (C).
Explanations :none.
Explanations :none.