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

count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

869


Explain how do you generate random numbers in c?

806


Explain what are linked list?

796


What is chain pointer in c?

773


How many types of arrays are there in c?

770


Mention four important string handling functions in c languages .

838


pierrot's divisor program using c or c++ code

1952


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

869


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

794


What are the advantages of external class?

785


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1647


program to convert a integer to string in c language'

2180


Explain the ternary tree?

786


Why can arithmetic operations not be performed on void pointers?

800


What are the 4 types of programming language?

766