Advertisement
STANAANDREY

p to f

Feb 28th, 2023
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int sum(int a, int b) {
  4.   return a + b;
  5. }
  6.  
  7. int dif(int a, int b) {
  8.   return a - b;
  9. }
  10.  
  11. int mul(int a, int b) {
  12.   return a * b;
  13. }
  14.  
  15. int div(int a, int b) {
  16.   return a / b;
  17. }
  18.  
  19. int main() {
  20.   int (*p[4])(int, int) = {sum, dif, mul, div};
  21.   for (int i = 0; i < 4; i++) {
  22.     printf("%d\n", (*p[i])(1, 2));
  23.   }
  24.   return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement