Function Pointer in C

Function Pointer in C

#include<stdio.h>

void add(int x,int y)      //functiom defition initialize at first to avoid function declaration
{

printf("addition is:%d\n",x+y);

}

main()
{

int a,b;
void (*ptr)(int,int);

ptr=&add;

printf("Enter value of a:");
scanf("%d",&a);

printf("Enter value of b:");
scanf("%d",&b);

(*ptr)(a,b);   //explicit
ptr(a,b);       //implicit
}

Related Posts