What will be the output of the following C code?
#include <stdio.h>
struct p
{
unsigned int x : 1;
unsigned int y : 1;
};
int main()
{
struct p p;
p.x = 1;
p.y = 2;
printf("%d\n", p.y);
}
#include <stdio.h>
struct p
{
unsigned int x : 1;
unsigned int y : 1;
};
int main()
{
struct p p;
p.x = 1;
p.y = 2;
printf("%d\n", p.y);
}A. 1
B. 2
C. 0
D. Depends on the compiler
Answer: Option C
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