what is a function pointer and how all to declare ,define
and implement it ???

Answer Posted / satish

Function pointer:
a function can be called not only by
its name,but also by other name which is called function
pointer.

void fact(int);
void main()
{
void(*p)(int);
printf("Enter n\n");
scanf("%d",&n);
p=fact;
fact(n);/*normal calling a function*/
(*p)(n); /*fn calling using function pointer*/

}
void (*p)(int n)
{
int ans=1;
while(n>0)
{
ans*=n--;
}

printf(" %d != %d",n,ans);

Is This Answer Correct ?    3 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When should you not use a type cast?

650


Why is %d used in c?

559


What is volatile c?

512


What are logical errors and how does it differ from syntax errors?

645


What is queue in c?

567






Is sizeof a keyword in c?

573


I have seen function declarations that look like this

589


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

902


Are there any problems with performing mathematical operations on different variable types?

563


What are near, far and huge pointers?

639


Explain how can you be sure that a program follows the ansi c standard?

852


Explain about the constants which help in debugging?

841


What is ## preprocessor operator in c?

607


in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above

586


Who is the founder of c language?

671