typedef function pointer example in C

Here it is!
#include <stdlib.h>
#include <stdio.h>
 
void add(int x, int y) {
    printf("%i\n", x+y);
}
 
void sub(int x, int y) {
    printf("%i\n", x-y);
}
 
// Define a type that is a function pointer with name: fptrmath
// The function returns void and accepts 2 integers.
typedef void (*fptrmath) (int,int);
 
int main() {

    // Create a local variable 'addition' of type fptrmath
    // which points to function 'add'
    fptrmath addition = add;
 
    // Similar to above
    fptrmath substraction = sub;
 
    int a = 5;
    int b = 10;
 
    // Use the local variables to call the methods.
    // addition is a local variable with type 'fptrmath' and value 'add'
    addition(b,a);
    substraction(b,a);
 
    return 0;
}

In Action!
gcc hello.c
./a.out
15
5