C MCQ set number 00722

1. What is the output of this C code?

  1.     #include <stdio.h>
  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

Answer: a [Reason:] None.

2. What is the output of this C code?

  1.     #include <stdio.h>
  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

Answer: b [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  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

Answer: d [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  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

Answer: c [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  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

Answer: a [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  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

Answer: c [Reason:] None.

7. What is the output of this C code?

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

a) Compile time error
b) 1
c) Undefined behaviour
d) Address of p

Answer

Answer: a [Reason:] None.

8. Presence of loop in a linked list can be tested by the compiler 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

Answer: b [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.