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