Which function is not called in the following C program? #include <stdio.h> void first() { printf("first"); } void second() { first(); } void third() { second(); } void main() { void (*ptr)(); ptr = third; ptr(); }
Function first
Function second
Function third
None of the mentioned
How to call a function without using the function name to send parameters?
typedefs
Function pointer
Both typedefs and Function pointer
None of the mentioned
Which of the following is a correct syntax to pass a Function Pointer as an argument?
Illegal application of ++ to void data type & pointer function initialized like a variable
None of the mentioned
What will be the output of the following C code? #include <stdio.h> int mul(int a, int b, int c) { return a * b * c; } void main() { int (*function_pointer)(int, int, int); function_pointer = mul; printf("The product of three numbers is:%d", function_pointer(2, 3, 4)); }
The product of three numbers is:24
Run time error
Nothing
Varies
What will be the output of the following C code?
#include <stdio.h> int mul(int a, int b, int c) { return a * b * c; } void main() { int (function_pointer)(int, int, int); function_pointer = mul; printf("The product of three numbers is:%d", function_pointer(2, 3, 4)); }
The product of three numbers is:24
Compile time error
Nothing
Varies
What will be the output of the following C code?
#include <stdio.h> void f(int (*x)(int)); int myfoo(int); int (*fooptr)(int); int ((*foo(int)))(int); int main() { fooptr = foo(0); fooptr(10); } int ((*foo(int i)))(int) { return myfoo; } int myfoo(int i) { printf("%d\n", i + 1); }
10
11
Compile time error
Undefined behaviour
What will be the output of the following C code? #include <stdio.h> int mul(int a, int b, int c) { return a * b * c; } void main() { int *function_pointer; function_pointer = mul; printf("The product of three numbers is:%d", function_pointer(2, 3, 4)); }
The product of three numbers is:24
Compile time error
Nothing
Varies
What will be the output of the following C code?
#include <stdio.h> int sub(int a, int b, int c) { return a - b - c; } void main() { int (*function_pointer)(int, int, int); function_pointer = ⊂ printf("The difference of three numbers is:%d", (*function_pointer)(2, 3, 4)); }
The difference of three numbers is:1
Run time error
The difference of three numbers is:-5
Varies
One of the uses for function pointers in C is __________
What will be the output of the following C code? #include <stdio.h> void f(int (*x)(int)); int myfoo(int i); int (*foo)(int) = myfoo; int main() { f(foo(10)); } void f(int (*i)(int)) { i(11); } int myfoo(int i) { printf("%d\n", i); return i; }
Compile time error
Undefined behaviour
10 11
10 Segmentation fault
What will be the output of the following C code?
#include <stdio.h> void f(int (*x)(int)); int myfoo(int); int (*foo)() = myfoo; int main() { f(foo); } void f(int(*i)(int )) { i(11); } int myfoo(int i) { printf("%d\n", i); return i; }