Structure and Union MCQs
Practice free Structure and Union multiple-choice questions with instant answer feedback and step-by-step solutions. Click an option to check yourself, reveal the full explanation, and work through all 190 questions — no login required.
Question 100hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *name;
};
struct student fun(void)
{
struct student s;
s.name = "alan";
return s;
}
void main()
{
struct student m = fun();
s.name = "turing";
printf("%s", m.name);
}Question 101hard
For what minimum value of x in a 32-bit Linux OS would make the size of s equal to 8 bytes?
struct temp
{
int a : 13;
int b : 8;
int c : x;
}s;Question 102hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
char *name;
struct p *next;
};
struct p *ptrary[10];
int main()
{
struct p p, q;
p.name = "xyz";
p.next = NULL;
ptrary[0] = &p
strcpy(q.name, p.name);
ptrary[1] = &q
printf("%s\n", ptrary[1]->name);
return 0;
}Advertisement
Question 103easy
Which of the following cannot be a structure member?
Question 104easy
Bit fields can only be declared as part of a structure.
Question 105easy
Which of the following reduces the size of a structure?
Advertisement
Question 106hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student n;
struct student *s = &n
(*s).c = "hello";
printf("%p\n%p\n", s, &n);
}Question 107easy
Which of the following uses structure?
Question 108easy
What is the order for the following C declarations?
short a : 17;
int long y : 33;