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 = abs(x - y);
  6. *mul = x * y;
  7. *mod = x % y;
  8. }
  9.  
  10. int main() {
  11. int x, y;
  12. int sum, diff, mul, mod;
  13.  
  14. scanf("%d %d", &x, &y);
  15.  
  16. cal(x, y, &sum, &diff, &mul, &mod);
  17.  
  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. }
  25.  
Success #stdin #stdout 0s 5280KB
stdin
4 6
stdout
x + y = 10
|x - y| = 2
x * y = 24
x % y = 4