250+ TOP MCQs on Complicated Declarations and Answers

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

Here is a listing of C multiple choice questions on “Complicated Declarations” along with answers, explanations and/or solutions:

1. Read the following expression?

a) ptr is pointer to int that converts its type to void
b) ptr is pointer to function passing int returning void
c) ptr is pointer to void that converts its type to int
d) ptr is pointer to function passing void returning int
Answer: b
Clarification: None.

2. Which of the following expression is true for the following C statement?

ptr is array with 3 elements of pointer to function returning pointer of int

a) int **ptr[3]();
b) int *(*ptr[3])();
c) int (*(*ptr[3])());
d) None of the mentioned
Answer: b
Clarification: None.

3. What makes the following declaration denote?

a) ptr is a function pointer that returns pointer to int type
b) ptr is a pointer to an int pointer
c) ptr is a pointer to pointer to type int
d) none of the mentioned
Answer: b
Clarification: None.

4. What makes the following declaration denote?

a) str is an array of 5 element pointer to type char
b) str is a pointer to an array of 5 elements
c) str is a function pointer of 5 elements returning char
d) none of the mentioned
Answer: a
Clarification: None.

5. Comment on the following declaration.

    int (*ptr)(); // i)
    char *ptr[]; // ii)

a) Both i) and ii) and cannot exist due to same name
b) i) is legal, ii) is illegal
c) i) is illegal, ii) is legal
d) Both i) and ii) will work legal and flawlessly
Answer: d
Clarification: None.

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

  1.     #include 
  2.     struct student
  3.     {
  4.         int no;
  5.         char name[20];
  6.     }
  7.     void main()
  8.     {
  9.         struct student s;
  10.         s.no = 8;
  11.         printf("hello");
  12.     }

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

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

  1.     #include 
  2.     struct student
  3.     {
  4.         int no = 5;
  5.         char name[20];
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         s.no = 8;
  11.         printf("hello");
  12.     }

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

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

  1.     #include 
  2.     struct student
  3.     {
  4.         int no;
  5.         char name[20];
  6.     };
  7.     void main()
  8.     {
  9.         student s;
  10.         s.no = 8;
  11.         printf("hello");
  12.     }

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

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

  1.     #include 
  2.     void main()
  3.     {
  4.         struct student
  5.         {
  6.             int no;
  7.             char name[20];
  8.         };
  9.         struct student s;
  10.         s.no = 8;
  11.         printf("%d", s.no);
  12.     }

a) Nothing
b) Compile time error
c) Junk
d) 8
Answer: d
Clarification: None.

10. Is the below declaration legal?

a) True
b) False
c) Undefined behaviour
d) Depends on the standard
Answer: b
Clarification: None.

Leave a Reply

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