Unions
- What will be the output of the following C code?
#include <stdio.h>
union U
{
int m;
char s;
};
int main()
{
union U u, uu;
u.m = 65;
uu.s = 32;
printf("%d\n", u.s);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
65
- What will be the output of the following C code?
#include <stdio.h>
union
{
int n;
char ch;
}U;
int main()
{
U.ch = 201;
printf("%d\n", sizeof(U));
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
sizeof(char)
- What will be the output of the following C code?
#include <stdio.h>
union
{
int n;
char ch;
}U;
int main()
{
U.n = 10;
printf("%d\n", sizeof(U));
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
sizeof(int)
- What will be the output of the following C code?
#include <stdio.h>
union Employee
{
int N;
float F;
};
void main()
{
union Employee emp;
emp.N = 26;
printf("%d", emp.N);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
26
- What will be the output of the following C code (Assuming size of int and float is 4)?
#include <stdio.h>
union
{
int Nval;
float Fval;
} U;
void main()
{
printf("%d", sizeof(U));
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
4