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 172hard
Which of the following will stop the loop at the last node of a linked list in the following C code snippet?
struct node
{
struct node *next;
};Question 173medium
In the following declaration of bit-fields, the constant-expression must be . . . . . . . .
struct-declarator:
declarator
type-specifier declarator opt : constant-expressionQuestion 174hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x;
int y;
};
int main()
{
struct p p1[] = {1, 2, 3, 4, 5, 6};
struct p *ptr1 = p1;
printf("%d %d\n", ptr1->x, (ptr1 + 2)->x);
}Advertisement
Question 175hard
What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)
#include <stdio.h>
union uTemp
{
double a;
int b[10];
char c;
}u;Question 176hard
What will be the output of the following C code?
#include <stdio.h>
union p
{
int x;
float y;
};
int main()
{
union p p, b;
p.x = 10;
printf("%f\n", p.y);
}Question 177hard
What will be the output of the following C code?
#include <stdio.h>
struct student fun(void)
{
struct student
{
char *name;
};
struct student s;
s.name = "alan";
return s;
}
void main()
{
struct student m = fun();
printf("%s", m.name);
}Advertisement
Question 178easy
In what situation, install function returns NULL?
Question 179hard
What will be the output of the following C code?
#include <stdio.h>
typedef struct p *q;
struct p
{
int x;
char y;
q ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->ptr->x);
return 0;
}Question 180hard
What will be the output of the following C code according to C99 standard?
#include <stdio.h>
struct p
{
int k;
char c;
float f;
};
int main()
{
struct p x = {.c = 97};
printf("%f\n", x.f);
}