What will be the output of the following C code?
#include <stdio.h>
struct p
{
char x : 2;
int y : 2;
};
int main()
{
struct p p;
p.x = 2;
p.y = 1;
p.x = p.x & p.y;
printf("%d\n", p.x);
}
#include <stdio.h>
struct p
{
char x : 2;
int y : 2;
};
int main()
{
struct p p;
p.x = 2;
p.y = 1;
p.x = p.x & p.y;
printf("%d\n", p.x);
}A. 0
B. Compile time error
C. Undefined behaviour
D. Depends on the standard
Answer: Option A
Related Questions on Structure and Union
Which of the following can be a member of a structure?
A. Function
B. Another structure
C. Enumeration
D. All of the above

Join The Discussion