add.c 326 B

12345678910111213141516171819202122
  1. #include <stdio.h>
  2. /* Add two integers */
  3. int add (int a, int b) {
  4. return a + b;
  5. }
  6. /* a function that takes a function pointer */
  7. int add2 (int (*pAdd) (int, int)) {
  8. return (* pAdd)(2, 3);
  9. }
  10. int
  11. main () {
  12. int (* pAdd)(int, int);
  13. pAdd = &add;
  14. int sum = (*pAdd)(2, 3);
  15. printf ("Sum is %d\n", sum);
  16. return 0;
  17. }