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 181hard
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;
s.c = m.c = "hi";
m.point = &s
(m.point)->c = "hey";
printf("%s\t%s\t", s.c, m.c);
}Question 182medium
Presence of code like "s.t.b = 10" indicates . . . . . . . .
Question 183hard
What will be the output of the following C code (Assuming size of int and float is 4)?
#include <stdio.h>
union
{
int ival;
float fval;
} u;
void main()
{
printf("%d", sizeof(u));
}Advertisement
Question 184medium
Which option is not possible for the following function call?
func(&s.a); //where s is a variable of type struct and a is the member of the struct.Question 185hard
What will be the output of the following C code?
#include <stdio.h>
struct temp
{
int a;
} s;
void func(struct temp s)
{
s.a = 10;
printf("%d\t", s.a);
}
main()
{
func(s);
printf("%d\t", s.a);
}Question 186hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x[2];
};
struct q
{
int *x;
};
int main()
{
struct p p1 = {1, 2};
struct q *ptr1 = (struct q*)&p1
ptr1->x = (struct q*)&p1.x
printf("%d\n", ptr1->x[0]);
}Advertisement
Question 187hard
What will be the output of the following C code?
#include <stdio.h>
struct
{
int k;
char c;
};
int main()
{
struct p;
p.k = 10;
printf("%d\n", p.k);
}Question 188hard
What will be the output of the following C code?
#include <stdio.h>
struct point
{
int x;
int y;
};
struct notpoint
{
int x;
int y;
};
void foo(struct point);
int main()
{
struct notpoint p1 = {1, 2};
foo(p1);
}
void foo(struct point p)
{
printf("%d\n", p.x);
}Question 189hard
What will be the output of the following C code?
#include <stdio.h>
typedef struct student
{
char *a;
}stu;
void main()
{
stu s;
s.a = "hi";
printf("%s", s.a);
}