11. What will be the output of the following C code?
#include <stdio.h>
union p
{
int x;
char y;
};
int main()
{
union p p, b;
p.y = 60;
b.x = 12;
printf("%d\n", p.y);
}
#include <stdio.h>
union p
{
int x;
char y;
};
int main()
{
union p p, b;
p.y = 60;
b.x = 12;
printf("%d\n", p.y);
}
12. What will be the output of the following C code?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int p = 10;
int main()
{
struct p x = {1, 97};
printf("%f %d\n", x.f, p);
}
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int p = 10;
int main()
{
struct p x = {1, 97};
printf("%f %d\n", x.f, p);
}
13. Which of the following structure declaration will throw an error?
14. What will be the output of the following C code?
#include <stdio.h>
union u
{
struct
{
unsigned char x : 2;
unsigned int y : 2;
}p;
int x;
};
int main()
{
union u u;
u.p.x = 2;
printf("%d\n", u.p.x);
}
#include <stdio.h>
union u
{
struct
{
unsigned char x : 2;
unsigned int y : 2;
}p;
int x;
};
int main()
{
union u u;
u.p.x = 2;
printf("%d\n", u.p.x);
}
15. What will be the output of the following C code?
#include <stdio.h>
struct student
{
int no;
char name[20];
}
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
#include <stdio.h>
struct student
{
int no;
char name[20];
}
void main()
{
struct student s;
s.no = 8;
printf("hello");
}
16. Which of the following is false about typedef?
17. Which function is responsible for recording the name "s" and the replacement text "t" in a table?
18. The number of distinct nodes the following struct declaration can point to is . . . . . . . .
struct node
{
struct node *left;
struct node *centre;
struct node *right;
};
struct node
{
struct node *left;
struct node *centre;
struct node *right;
};
19. In the following declaration of bit-fields, the constant-expression specifies . . . . . . . .
struct-declarator:
declarator
type-specifier declarator opt : constant-expression
struct-declarator:
declarator
type-specifier declarator opt : constant-expression
20. What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}
Read More Section(Structure and Union)
Each Section contains maximum 100 MCQs question on Structure and Union. To get more questions visit other sections.