Home » C Programming » Pointers » Question
  1. 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));
    }
    1. Nothing
    2. Compilation Error
    3. Garbage value
    4. The product of three numbers is : 240
    5. 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;



Your comments will be displayed only after manual approval.