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 82hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x;
char y;
struct p *ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}Question 83hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m
s->c = "hello";
printf("%s", s->c);
}Question 84hard
Comment on the output of the following C code.
#include <stdio.h>
struct temp
{
int a;
int b;
int c;
};
main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
}Advertisement
Question 85easy
Which of the following operation is illegal in structures?
Question 86easy
The correct syntax to access the member of the ith structure in the array of structures is?
Assuming: struct temp
{
int b;
}s[50];Question 87hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x;
char y;
};
int main()
{
struct p p1[] = {1, 92, 3, 94, 5, 96};
struct p *ptr1 = p1;
int x = (sizeof(p1) / sizeof(ptr1));
if (x == 1)
printf("%d\n", ptr1->x);
else
printf("false\n");
}Advertisement
Question 88hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
m.point = s;
(m.point)->c = "hey";
printf("%s", s.c);
}Question 89hard
What will be the output of the following C code?
#include <stdio.h>
union stu
{
int ival;
float fval;
};
void main()
{
union stu r;
r.ival = 5;
printf("%d", r.ival);
}Question 90hard
What will be the output of the following C code?
#include <stdio.h>
union
{
int x;
char y;
}p;
int main()
{
p.y = 60;
printf("%d\n", sizeof(p));
}