Write a C program to illustrate the use of function pointer.

 

#include<stdio.h>
void main()
{
int sum(int, int);
int (*p)(int,int);
int a,b,r;
clrscr();
printf("input the two integers:\n");
scanf("%d%d",&a,&b);
p=sum;
r=(*p)(a,b);
printf("the sum of %4d and %4d is :%5d",a,b,r);
getch();
}
int sum(int m, int n)
{
return(m+n);
}

 

 

Output:
input the two integers:
100
150
the sum of 100 and 150 is : 250