fork download
  1. #include <stdlib.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 = 2;
  12. int y = 5;
  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 0.01s 5284KB
stdin
Standard input is empty
stdout
x = 2, y = 5
xとyの和は: 7
xとyの差は: 3
xとyの積は: 10
xとyの商は: 0