250+ TOP MCQs on Self-Referential Structures and Answers

C helps anyone preparing for AMD and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear AMD interviews on C Programming language.

Here is a listing of C question bank on “Self Referential Structures” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     struct student
  3.     {
  4.         char *c;
  5.         struct student *point;
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         struct student m;
  11.         s.c = m.c = "hi";
  12.         m.point = &s;
  13.         (m.point)->c = "hey";
  14.         printf("%st%st", s.c, m.c);
  15.     }

a) hey hi
b) hi hey
c) Run time error
d) hey hey
Answer: a
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     struct student
  3.     {
  4.         char *c;
  5.         struct student *point;
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         struct student m;
  11.         m.point = s;
  12.         (m.point)->c = "hey";
  13.         printf("%s", s.c);
  14.     }

a) Nothing
b) Compile time error
c) hey
d) Varies
Answer: b
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     struct student
  3.     {
  4.         char *c;
  5.         struct student point;
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         s.c = "hello";
  11.         printf("%s", s.c);
  12.     }

a) hello
b) Nothing
c) Varies
d) Compile time error
Answer: d
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     struct student
  3.     {
  4.         char *c;
  5.         struct student *point;
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         printf("%d", sizeof(s));
  11.     }

a) 5
b) 9
c) 8
d) 16
Answer: c
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     struct student
  3.     {
  4.         char *c;
  5.         struct student *point;
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         struct student *m = &s;
  11.         printf("%d", sizeof(student));
  12.     }

a) Compile time error
b) 8
c) 5
d) 16
Answer: a
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     struct p
  3.     {
  4.         int x;
  5.         char y;
  6.         struct p *ptr;
  7.     };
  8.     int main()
  9.     {
  10.         struct p p = {1, 2, &p};
  11.         printf("%dn", p.ptr->x);
  12.         return 0;
  13.     }

a) Compile time error
b) Undefined behaviour
c) 1
d) 2
Answer: c
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  2.     typedef struct p *q;
  3.     struct p
  4.     {
  5.         int x;
  6.         char y;
  7.         q ptr;
  8.     };
  9.     int main()
  10.     {
  11.         struct p p = {1, 2, &p};
  12.         printf("%dn", p.ptr->x);
  13.         return 0;
  14.     }

a) Compile time error
b) 1
c) Undefined behaviour
d) Address of p
Answer: b
Clarification: None.

8. Presence of loop in a linked list can be tested by ________
a) Traveling the list, if NULL is encountered no loop exists
b) Comparing the address of nodes by address of every other node
c) Comparing the the value stored in a node by a value in every other node
d) None of the mentioned
Answer: b
Clarification: None.

  250+ TOP MCQs on Date and Time Function and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top