GATE CSE C Programming Practice Test – Structures & Unions | Set 1

Questions 1-5 of 100

Your score 0/100 0 answered
Correct 0 Incorrect 0 Unanswered 100 Accuracy 0%

Question 1

MCQ · Single Correct 1 mark

Consider the following C declarations:

CODE
struct node {
    int i;
    float j;
};
struct node *s[10];

Which of the following describes 's'?

Answers for question 1

Question 2

MCQ · Single Correct 2 mark

Which choice is printed when the following program is executed?

C
#include <stdio.h>
struct test {
    int i;
    char *c;
} st[] = {5, "become", 4, "better", 6, "jungle", 8, "ancestor", 7, "brother"};

int main(void) {
    struct test *p = st;
    p += 1;
    ++p->c;
    printf("%s,", p++->c);
    printf("%c,", *++p->c);
    printf("%d,", p[0].i);
    printf("%s", p->c);
    return 0;
}
Answers for question 2

Question 3

MCQ · Single Correct 2 mark

Consider the following C typedef and functions:

C
typedef struct {
    char *a;
    char *b;
} t;

void f1(t s) {
    s.a = "U";
    s.b = "V";
}

void f2(t *p) {
    p->a = "V";
    p->b = "W";
}

int main(void) {
    static t s = {"A", "B"};
    f1(s);
    printf("%s %s ", s.a, s.b);
    f2(&s);
    printf("%s %s", s.a, s.b);
    return 0;
}
Answers for question 3

Question 4

MCQ · Single Correct 1 mark

What is the size of the following C union on a 32-bit system where int is 4 bytes?

CODE
union Data {
    int i;
    char str[20];
    double d;
};
Answers for question 4

Question 5

MCQ · Single Correct 1 mark

Consider structure question #5:

CODE
struct Item_5 {
    int id;
    char name[10];
};
struct Item_5 it = {5, "GATE"};
struct Item_5 *ptr = &it;

What is the value of 'ptr->id'?

Answers for question 5
Scroll to Top