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 118medium
The number of distinct nodes the following struct declaration can point to is . . . . . . . .
struct node
{
struct node *left;
struct node *centre;
struct node *right;
};Question 119medium
In the following declaration of bit-fields, the constant-expression specifies . . . . . . . .
struct-declarator:
declarator
type-specifier declarator opt : constant-expressionQuestion 120hard
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));
}Advertisement
Question 121hard
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, .k = 1, 3};
printf("%f \n", x.f);
}Question 122hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
int no = 5;
char name[20];
};
void main()
{
struct student s;
s.no = 8;
printf("hello");
}Question 123hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *name;
};
struct student s;
struct student fun(void)
{
s.name = "newton";
printf("%s\n", s.name);
s.name = "alan";
return s;
}
void main()
{
struct student m = fun();
printf("%s\n", m.name);
m.name = "turing";
printf("%s\n", s.name);
}Advertisement
Question 124hard
What will be the output of the following C code?
#include <stdio.h>
typedef int integer;
int main()
{
int i = 10, *ptr;
float f = 20;
integer j = i;
ptr = &j
printf("%d\n", *ptr);
return 0;
}Question 125medium
What happens when install(s, t) finds that the name being installed is already present in the table?
Question 126hard
What will be the output of the following C code?
#include <stdio.h>
struct point
{
int x;
int y;
};
void foo(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4};
foo(p1);
}
void foo(struct point p[])
{
printf("%d\n", p[1].x);
}