250+ TOP MCQs on Table Lookup and Answers

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

Here is a listing of online C quiz on “Table Lookup” 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 a[5];
  5.     };
  6.     void main()
  7.     {
  8.         struct student s[] = {"hi", "hey"};
  9.         printf("%c", s[0].a[1]);
  10.     }

a) h
b) i
c) e
d) y
Answer: b
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         char *a[3] = {"hello", "this"};
  5.         printf("%s", a[1]);
  6.     }

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

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

  1.     #include 
  2.     void main()
  3.     {
  4.         int lookup[100] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  5.         printf("%d", lookup[3]);
  6.     }

a) 2
b) 4
c) Compile time error
d) 3
Answer: d
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         char *a[3][3] = {{"hey", "hi", "hello"}, {"his", "her", "hell"}
  5.         , {"hellos", "hi's", "hmm"}};
  6.         printf("%s", a[1][1]);
  7.     }

a) her
b) hi
c) Compile time error
d) hi’s
Answer: a
Clarification: None.

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

  1.     #include 
  2.     struct p
  3.     {
  4.         char *name;
  5.         struct p *next;
  6.     };
  7.     struct p *ptrary[10];
  8.     int main()
  9.     {
  10.         struct p p;
  11.         p->name = "xyz";
  12.         p->next = NULL;
  13.         ptrary[0] = &p;
  14.         printf("%sn", p->name);
  15.         return 0;
  16.     }

a) Compile time error
b) Segmentation fault/code crash
c) xyz
d) Undefined behaviour
Answer: a
Clarification: None.

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

  1.     #include 
  2.     struct p
  3.     {
  4.         char *name;
  5.         struct p *next;
  6.     };
  7.     struct p *ptrary[10];
  8.     int main()
  9.     {
  10.         struct p p;
  11.         p.name = "xyz";
  12.         p.next = NULL;
  13.         ptrary[0] = &p;
  14.         printf("%sn", ptrary[0]->name);
  15.         return 0;
  16.     }

a) Compile time error
b) Segmentation fault
c) Undefined behaviour
d) xyz
Answer: d
Clarification: None.

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

  1.     #include 
  2.     struct p
  3.     {
  4.         char *name;
  5.         struct p *next;
  6.     };
  7.     struct p *ptrary[10];
  8.     int main()
  9.     {
  10.         struct p p, q;
  11.         p.name = "xyz";
  12.         p.next = NULL;
  13.         ptrary[0] = &p;
  14.         strcpy(q.name, p.name);
  15.         ptrary[1] = &q;
  16.         printf("%sn", ptrary[1]->name);
  17.         return 0;
  18.     }

a) Compile time error
b) Segmentation fault/code crash
c) Depends on the compiler
d) xyz
Answer: b
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         struct p
  5.         {
  6.             char *name;
  7.             struct p *next;
  8.         };
  9.         struct p p, q;
  10.         p.name = "xyz";
  11.         p.next = NULL;
  12.         ptrary[0] = &p;
  13.         strcpy(q.name, p.name);
  14.         ptrary[1] = &q;
  15.         printf("%sn", ptrary[1]->name);
  16.         return 0;
  17.     }

a) Compile time error
b) Depends on the compiler
c) Undefined behaviour
d) xyz
Answer: c
Clarification: None.

Leave a Reply

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