-
What will be the output of the following C code?
#include <stdio.h>
int calc(int m, int n, int t)
{
return m * n * t;
}
void main()
{
int *fun_ptr;
fun_ptr = calc;
printf("The product of three numbers is : %d",
fun_ptr(12, 10, 2));
}
-
- Nothing
- Compilation Error
- Garbage value
- The product of three numbers is : 240
- None of these
Correct Option: B
Compilation Error
main.c: In function ‘main’:
main.c:9:17: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
fun_ptr = calc;
^
main.c:11:9: error: called object ‘fun_ptr’ is not a function or function pointer
fun_ptr(12, 31, 14));
^~~~~~~
main.c:8:14: note: declared here
int *fun_ptr;