fork download
  1. #include <stdio.h>
  2.  
  3. void cal(int x,int y,int *sum,int *diff,int *mul,int *mod);
  4.  
  5. int main(void)
  6. {
  7. int x, y, sum, diff, mul, mod;
  8.  
  9.  
  10. scanf("%d", &x);
  11. scanf("%d", &y);
  12.  
  13. cal(x, y, &sum, &diff, &mul, &mod);
  14.  
  15. printf("x = %d, y = %d\n", x, y);
  16. printf("sum = %d\n", sum);
  17. printf("diff = %d\n", diff);
  18. printf("mul = %d\n", mul);
  19. printf("mod = %d\n", mod);
  20.  
  21. return 0;
  22. }
  23.  
  24. void cal(int x,int y,int *sum,int *diff,int *mul,int *mod)
  25. {
  26. *sum = x + y;
  27. if (x > y)
  28. *diff = x - y;
  29. else
  30. *diff = y - x;
  31.  
  32. *mul = x * y;
  33.  
  34. if (y != 0)
  35. *mod = x / y;
  36. else
  37. *mod = 0;
  38.  
  39. }
Success #stdin #stdout 0.01s 5296KB
stdin
 5 
 3
stdout
x = 5, y = 3
sum = 8
diff = 2
mul = 15
mod = 1