fork(3) 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. printf("x:");
  9. scanf("%d",&x);
  10. printf("y:");
  11. scanf("%d",&y);
  12.  
  13. cal(x,y,&sum,&diff,&mul,&mod);
  14.  
  15. printf("sum:%d,diff:%d,mul:%d,mod:%d\n",sum,diff,mul,mod);
  16. return 0;
  17. }
  18.  
  19. void cal(int x, int y, int *sum, int *diff, int *mul, int *mod)
  20. {
  21. *sum=x+y;
  22. if (x > y) {
  23. *diff = x - y;
  24. } else {
  25. *diff = y - x;
  26. }
  27. *mul=x*y;
  28. *mod=x/y;
  29. }
Success #stdin #stdout 0s 5284KB
stdin
6
3
stdout
x:y:sum:9,diff:3,mul:18,mod:2