Structure and Union MCQs

190 questionsC-ProgramPage 15 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 127hard
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", m.c);
}
Question 128hard
Which member of the union will be active after REF LINE in the following C code?
#include <stdio.h>
union temp
{
    int a;
    float b;
    char c;
};
union temp s = {1,2.5,’A’}; //REF LINE
Question 129easy
Which of the following return-type cannot be used for a function in C?
Advertisement
Question 130hard
What will be the output of the following C code?
#include <stdio.h>
struct
{
    int k;
    char c;
} p;
int p = 10;
int main()
{
    p.k = 10;
    printf("%d %d\n", p.k, p);
}
Question 131hard
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 %d\n", p->x, ++p->x);
}
Question 132hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
    unsigned int x : 2;
    unsigned int y : 2;
};
int main()
{
    struct p p;
    p.x = 3;
    p.y = 1;
    printf("%d\n", sizeof(p));
}
Advertisement
Question 133hard
What type of data is holded by variable u int in the following C code?
#include <stdio.h>
union u_tag
{
    int ival;
    float fval;
    char *sval;
} u;
Question 134hard
What will be the output of the following C code?
#include <stdio.h>
typedef struct p
{
    int x, y;
};
int main()
{
    p k1 = {1, 2};
    printf("%d\n", k1.x);
}
Question 135hard
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, .f = 3, .k = 1};
    printf("%f\n", x.f);
}
Structure and Union MCQs with Answers & Solutions — C-Program | GrabStudy