Structure and Union MCQs

190 questionsC-ProgramPage 13 of 22

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 109hard
What will be the output of the following C code?
#include <stdio.h>
union u
{
    struct
    {
        unsigned char x : 2;
        unsigned int y : 2;
    }p;
    int x;
};
int main()
{
    union u u.p = {2};
    printf("%d\n", u.p.x);
}
Question 110medium
Presence of loop in a linked list can be tested by . . . . . . . .
Question 111hard
What will be the output of the following C code?
#include <stdio.h>
union p
{
    int x;
    char y;
};
int main()
{
    union p p, b;
    p.y = 60;
    b.x = 12;
    printf("%d\n", p.y);
}
Advertisement
Question 112hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
    int k;
    char c;
    float f;
};
int p = 10;
int main()
{
    struct p x = {1, 97};
    printf("%f %d\n", x.f, p);
}
Question 113medium
Which of the following structure declaration will throw an error?
Question 114hard
What will be the output of the following C code?
#include <stdio.h>
union u
{
    struct
    {
        unsigned char x : 2;
        unsigned int y : 2;
    }p;
    int x;
};
int main()
{
    union u u;
    u.p.x = 2;
    printf("%d\n", u.p.x);
}
Advertisement
Question 115hard
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    int no;
    char name[20];
}
void main()
{
    struct student s;
    s.no = 8;
    printf("hello");
}
Question 116easy
Which of the following is false about typedef?
Question 117medium
Which function is responsible for recording the name "s" and the replacement text "t" in a table?