#include <stdio.h>
#include <stdlib.h>
int funman(int (*) (int x, int y), int x, int y);
int add(int x, int y);
int mul(int x, int y);
int main(void)
{
int i, j, res;
printf("Enter two integer numbers: ");
scanf("%d %d", &i, &j);
res = funman(add, i, j);
printf("\nres is : %d", res);
res = funman(mul, i, j);
printf("\nres is : %d", res);
printf("\n");
return 0;
}
int funman(int (*ptofun) (int x, int y), int x, int y)
{
return (*ptofun)(x, y);
}
int add(int x, int y)
{
return x + y;
}
int mul(int x, int y)
{
return x * y;
}
Passing Function to a Function as Parameter
Share This
Tags
# C Programming Language
# Technology
Share This
About BunksAllowed
Technology
Labels:
C Programming Language,
Technology
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.