Sail E0 Webinar
Question

Point out the error in the following program.


#include<stdio.h>
int main()
{
int (*p) () = fun:
(*p) ();
return 0;
}
int fun ()
{
printf("Placementadda&#92;n");
return 0;
}


Options:
A .  Error: in int(*p)() = fun;
B .  Error: fun() prototype not defined
C .  No error
D .  None of these
Answer: Option B


The compiler will not know that the function int fun() exists. So we have to
define the function prototype of int fun();
To overcome this error, see the below program


#include<stdio.h>
int fun(); /* function prototype */
int main()
{
int(*p) () = fun;
(*p) ();
return 0;
}
int fun()
{
printf("Placementadda&#92;n");
return 0;
}



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers