C Programming - Functions - Discussion
Discussion Forum : Functions - Find Output of Program (Q.No. 18)
18.
What will be the output of the program?
#include<stdio.h>
int fun(int(*)());
int main()
{
fun(main);
printf("Hi\n");
return 0;
}
int fun(int (*p)())
{
printf("Hello ");
return 0;
}
Discussion:
33 comments Page 2 of 4.
Giridhar said:
6 years ago
Pointer function "*p() " which is referring to main is not invoking in "fun(int (*p) ()) ". So, the main() function is not invoked in recursive.
Radhika said:
1 decade ago
We can access the variable of function. I think that is the advantage of passing a function as argument to another function.
Amruta said:
8 years ago
int (*p) () p is a function pointer which should point to a function taking no args and returning int.
Narendra said:
1 decade ago
Everyone just explaining therotically. Please explain in deep and practically line by line.
Ram said:
7 years ago
Is this the correct way of passing any function into another function? Please explain.
Robin said:
1 decade ago
If we are not using the address of main function then what is the need for passing it?
Shravana said:
1 decade ago
Sorry guys. I can't understand the line: int fun(int(*p)()). Can anyone explain it?
Raju said:
1 decade ago
If I passs any arguments on calling function then how will the function work.
ASHISh said:
1 decade ago
Yes, I agree with Manu.
What is the use of function pointer in this program?
What is the use of function pointer in this program?
Sujith said:
1 decade ago
They did not use the p anywhere in the fun just they printing the statement!
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers