Log In Register

Units


Pointers To Functions - Questions and Answers

 

Practice these Pointers To Functions 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 Pointers To Functions for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Pointers To Functions of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Pointers To Functions.
– 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 Pointers To Functions 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  Pointers To Functions topic of C Programming:

 

1.

What is the output of this C code?

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

Answer: Option D

Explanation:

2.

Which of the following is not possible in C?

Answer: Option D

Explanation:

3.

What is the output of this C code?

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

Answer: Option C

Explanation:

4.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int mul(int a, int b, int c)
  3.     {
  4.         return a * b * c;
  5.     }
  6.     void main()
  7.     {
  8.         int *function_pointer;
  9.         function_pointer = mul;
  10.         printf("The product of three numbers is:%d",
  11.         function_pointer(2, 3, 4));
  12.     }

Answer: Option C

Explanation:

5.

What is the output of this C code?

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

Answer: Option C

Explanation:

6.

Correct syntax to pass a Function Pointer as an argument

Answer: Option D

Explanation:

7.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int mul(int a, int b, int c)
  3.     {
  4.         return a * b * c;
  5.     }
  6.     void main()
  7.     {
  8.         int (function_pointer)(int, int, int);
  9.         function_pointer = mul;
  10.         printf("The product of three numbers is:%d",
  11.         function_pointer(2, 3, 4));
  12.     }

Answer: Option C

Explanation:

8.

How to call a function without using the function name to send parameters?

Answer: Option C

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int mul(int a, int b, int c)
  3.     {
  4.         return a * b * c;
  5.     }
  6.     void main()
  7.     {
  8.         int (*function_pointer)(int, int, int);
  9.         function_pointer  =  mul;
  10.         printf("The product of three numbers is:%d",
  11.         function_pointer(2, 3, 4));
  12.     }

Answer: Option D

Explanation:

10.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f(int);
  3.     void (*foo)(void) = f;
  4.     int main(int argc, char *argv[])
  5.     {
  6.         foo(10);
  7.         return 0;
  8.     }
  9.     void f(int i)
  10.     {
  11.         printf("%d\n", i);
  12.     }

Answer: Option B

Explanation:

11.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int sub(int a, int b, int c)
  3.     {
  4.         return a - b - c;
  5.     }
  6.     void main()
  7.     {
  8.         int (*function_pointer)(int, int, int);
  9.         function_pointer = &sub;
  10.         printf("The difference of three numbers is:%d",
  11.         (*function_pointer)(2, 3, 4));
  12.     }

Answer: Option B

Explanation:

12.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f(int);
  3.     void (*foo)() = f;
  4.     int main(int argc, char *argv[])
  5.     {
  6.         foo(10);
  7.         return 0;
  8.     }
  9.     void f(int i)
  10.     {
  11.         printf("%d\n", i);
  12.     }

Answer: Option C

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void first()
  3.     {
  4.         printf("Hello World");
  5.     }
  6.     void main()
  7.     {
  8.         void *ptr() = first;
  9.         ptr++
  10.         ptr();
  11.     }

Answer: Option A

Explanation:

14.

What is the output of this C code?

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

Answer: Option A

Explanation:

15.

Which function is not called in the following program?

  1.     #include <stdio.h>
  2.     void first()
  3.     {
  4.         printf("first");
  5.     }
  6.     void second()
  7.     {
  8.         first();
  9.     }
  10.     void third()
  11.     {
  12.         second();
  13.     }
  14.     void main()
  15.     {
  16.         void (*ptr)();
  17.         ptr = third;
  18.         ptr();
  19.     }

Answer: Option D

Explanation: