Log In Register

Units


Complicated Declarations - Questions and Answers

 

Practice these Complicated Declarations  under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Complicated Declarations for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Complicated Declarations of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Complicated Declarations .
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Complicated Declarations under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Complicated Declarations topic of C Programming:

 

1.

What is the output of this C code?

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

Answer: Option B

Explanation:

2.

What is the output of this C code?

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

Answer: Option A

Explanation:

3.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void (*(f)())(int, float);
  3.     typedef void (*(*x)())(int, float);
  4.     void foo(int i, float f);
  5.     int main()
  6.     {
  7.         x p = f;
  8.         p();
  9.     }
  10.     void (*(f)())(int, float)
  11.     {
  12.         return foo;
  13.     }
  14.     void foo(int i, float f)
  15.     {
  16.         printf("%d %f\n", i, f);
  17.     }

Answer: Option A

Explanation:

4.

What is the output of this C code?

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

Answer: Option D

Explanation:

5.

What is the output of this C code?

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

Answer: Option B

Explanation:

6.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int *((*x)())[2];
  5.         x();
  6.         printf("after x\n");
  7.     }
  8.     int *((*x)())[2]
  9.     {
  10.         int **str;
  11.         str = (int*)malloc(sizeof(int)* 2);
  12.         return str;
  13.     }

Answer: Option C

Explanation:

7.

Comment on the following declaration?
    int (*ptr)(); // i)
    char *ptr[]; // ii)

Answer: Option A

Explanation:

8.

Is the below declaration legal?
     int* ((*x)())[2];

Answer: Option C

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void (*(f)())(int, float);
  3.     void (*(*x)())(int, float) = f;
  4.     void ((*y)(int, float));
  5.     void foo(int i, float f);
  6.     int main()
  7.     {
  8.         y = x();
  9.         y(1, 2);
  10.     }
  11.     void (*(f)())(int, float)
  12.     {
  13.         return foo;
  14.     }
  15.     void foo(int i, float f)
  16.     {
  17.         printf("%d %f\n", i, f);
  18.     }

Answer: Option D

Explanation:

10.

What is the output of this C code?

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

Answer: Option D

Explanation:

11.

What do the following declaration denote?
    int **ptr;

Answer: Option A

Explanation:

12.

What is the output of this C code?

  1.     #include <stdio.h>
  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("%s", s.name);
  12.     }

Answer: Option D

Explanation:

13.

What is the output of this C code?

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

Answer: Option C

Explanation:

14.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void (*(f)())(int, float);
  3.     typedef void (*(*x)())(int, float);
  4.     void foo(int i, float f);
  5.     int main()
  6.     {
  7.         x = f;
  8.         x();
  9.     }
  10.     void (*(f)())(int, float)
  11.     {
  12.         return foo;
  13.     }
  14.     void foo(int i, float f)
  15.     {
  16.         printf("%d %f\n", i, f);
  17.     }

Answer: Option D

Explanation:

15.

What is the output of this C code?

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

Answer: Option B

Explanation: