why we need function pointers?

Answer Posted / kirankumaryakkala

a pointer that holds the address of a function.
in writing the interrupt service routines(isr),memory virus
programs, etc..
as simply, if u wanna execute one function out of two or
more funcitons( the selection based dynamically)

ex. int add(int a, int b)
int sub(int a, int b)
int mul(int a, int b)

int (*ptr)(int a, int b) //function pointer declaration to
hold a function that takes two integers, returns one integer

here,
ptr= it can assign any function name that is going to execute


Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

1068


Explain how can I avoid the abort, retry, fail messages?

821


Write a program to check whether a number is prime or not using c?

808


What is indirection in c?

810


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

1820


What is p in text message?

745


What are structure types in C?

870


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1860


Write a simple code fragment that will check if a number is positive or negative.

918


Is malloc memset faster than calloc?

804


Write a program to show the change in position of a cursor using c

828


What is structure in c language?

834


What is signed and unsigned?

837


what is use of malloc and calloc?

1670


Explain two-dimensional array.

827