Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int calculate(int a, int b, int(*function)(int, int)){
- return (*function)(a, b);
- }
- static int plus(int a, int b){
- return a + b;
- }
- static int minus(int a, int b){
- return a - b;
- }
- int main(){
- int sum = calculate(5, 10, &plus);
- int diff = calculate(10, 5, &minus);
- return sum - diff;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement