fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod) {
  5. *sum = abs(x + y);
  6. *diff = abs(x - y);
  7. *mul = abs(x * y);
  8. *mod = (y != 0) ? abs(x / y) : 0;
  9. }
  10.  
  11. int main() {
  12. int x = 3, y = 2;
  13. int sum, diff, mul, mod;
  14.  
  15.  
  16. cal(x, y, &sum, &diff, &mul, &mod);
  17.  
  18.  
  19. printf("合計:%d\n", sum);
  20. printf("差: %d\n", diff);
  21. printf("掛け算: %d\n", mul);
  22. printf("商: %d\n", mod);
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
合計:5
差: 1
掛け算: 6
商: 1