function pointer
Mon Jun 13 2022 17:25:28 GMT+0000 (Coordinated Universal Time)
Saved by
@KanishqJ8
#include <stdio.h>
#include <stdlib.h>
int sum(int a, int b){
return a+b;
}
void greetHelloAndExecute(int(*fptr)(int,int)){
printf("hello user\n");
printf("the sum of 5 and 7 is %d\n",fptr(5,7));
}
void greet(int (*fptr)(int,int)){
printf("goodmorning user\n");
printf("the sum of 5 and 7 is %d\n",fptr(5,7));
}
int main(){
int(*ptr)(int,int);
ptr=sum;
greet(ptr);
// printf("sum of 1 and 2 is %d\n",sum(1,2));
// int(*fptr)(int,int);//declaring a function pointer
// fptr=∑//creating a function pointer
// int d=(*fptr)(4,6);//dereferencing a function pointer
// printf("the value of d is %d\n",d);
return 0;
}
content_copyCOPY
Comments