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