fork download
  1. #include <stdio.h>
  2.  
  3. void cal(int x, int y, int *sum, int*diff, int *mul, int*mod){
  4.  
  5. *sum = x + y;
  6.  
  7. if(x>=y)
  8. *diff = x - y;
  9. else
  10. *diff = y - x;
  11.  
  12. *mul = x * y;
  13. *mod = x % y;
  14. }
  15.  
  16. int main(void) {
  17. int x,y,sum,diff,mul,mod;
  18. scanf("%d %d",&x,&y);
  19.  
  20. cal(x,y,&sum,&diff,&mul,&mod);
  21.  
  22. printf("xとyの和は%d\n",sum);
  23. printf("xとyの差は%d\n",diff);
  24. printf("xとyの積は%d\n",mul);
  25. printf("xをyで割った余りは%d\n",mod);
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 5320KB
stdin
8 6
stdout
xとyの和は14
xとyの差は2
xとyの積は48
xをyで割った余りは2