What will be the output of the following C code?
#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}
#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}A. Compile time error, declaration of a function inside main
B. Compile time error, no definition of function fn_ptr
C. Compile time error, illegal application of statement fn_ptr = add
D. No Run time error, output is 5
Answer: Option D

Join The Discussion