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. *mul = x * y;
  6. *mod = x % y;
  7.  
  8. if (x - y < 0) {
  9. *diff = -(x - y);
  10. } else {
  11. *diff = x - y;
  12. }
  13. }
  14.  
  15. int main() {
  16. int x, y, sum, diff, mul, mod;
  17.  
  18. printf("xの値を入力してください: ");
  19. scanf("%d", &x);
  20. printf("yの値を入力してください: ");
  21. scanf("%d", &y);
  22.  
  23. cal(x, y, &sum, &diff, &mul, &mod);
  24.  
  25. printf("x + y = %d\n", sum);
  26. printf("x - y = %d\n", diff);
  27. printf("x * y = %d\n", mul);
  28. printf("x / y = %d\n", x / y);
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5280KB
stdin
4
5
stdout
xの値を入力してください: yの値を入力してください: x + y = 9
x - y = 1
x * y = 20
x / y = 0