1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

#include <stdio.h>

int add(int a, int b) {
    return a + b;
}
int subtract(int a, int b) {
    return a + b;
}

int calculate(int (*operator)(int, int), int a, int b) {
    return operator(a, b);
}

int main(int argc, char *argv[]) {

    int sum = calculate(add, 5, 3);
    printf("result == %d\n", sum);

    int difference = calculate(add, 5, 3);
    printf("result == %d\n", difference);

    return 0;
}

This content is protected and may not be shared, uploaded, or distributed.    © 2019 Alexander J. Quinn.