Unions
- In the following C code, we can access the 1st character of the string sval by using _______.
#include <stdio.h>
struct
{
char *Name;
union
{
char *Str;
} u;
} tab[15];
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Both tab[i].u.Str[0]. & *tab[i].u.Str
- Members of a union are accessed as________________.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
both union-pointer->member & union-name.member
- What type of data is holded by variable u int in the following C code?
#include <stdio.h>
union Example
{
int Nval;
float Fval;
char *Sval;
} e;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Will be large enough to hold the largest of the three types;
- What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)
#include <stdio.h>
union Test
{
double n1;
int n2[10];
char n;
}t;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
40
- Which member of the union will be active after REF LINE in the following C code?
#include <stdio.h>
union test
{
int n;
float fl;
char ch;
};
union test t = {11,12.25,’N’}; //REF LINE
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
n