Since we know that In function,the function name itself can act as the address to the function just like it was happening in array.
So the given below program is correctly working:-
#include<stdio.h>
int sum(int x,int y)
{
return x+y;
}
int (*fb)(int,int);
int main()
{
fb=sum; // I will modify here
printf("%d",fb(8,6));
}
Output:-14
But when I am doing just a one modification on modification line as
fb=∑
then also the program is correctly working as shown below:-
#include<stdio.h>
int sum(int x,int y)
{
return x+y;
}
int (*fb)(int,int);
int main()
{
fb=∑ //modified here
printf("%d",fb(8,6));
}
Output:- 14
How this is happening?
And then also when I am modifying in printf then also it is working as shown below:-
#include<stdio.h>
int sum(int x,int y)
{
return x+y;
}
int (*fb)(int,int);
int main()
{
fb=∑
printf("%d",(*fb)(8,6));
}
Output:- 14
So from the above I am seeing that
fb=sum; or fb=∑ both are equivalent
and (*fb)(8,6) and (fb)(8,6) are equivalent.
How this is happening?