fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int a, b, c;
  6. scanf("%d %d %d", &a, &b, &c);
  7.  
  8. switch (c) {
  9. case 1:
  10. printf("%d + %d = %d", a, b, a + b);
  11. break;
  12.  
  13. case 2:
  14. printf("%d - %d = %d", a, b, a - b);
  15. break;
  16.  
  17. case 3:
  18. printf("%d * %d = %d", a, b, a * b);
  19. break;
  20.  
  21. case 4: {
  22. if (b == 0) {
  23. printf("not defined");
  24. break;
  25. }
  26.  
  27. int div = a / b;
  28. int mod = a % b;
  29.  
  30. switch (mod == 0) {
  31. case 1:
  32. printf("%d ÷ %d = %d", a, b, div);
  33. break;
  34. case 0:
  35. printf("%d ÷ %d = %d ... %d", a, b, div, mod);
  36. break;
  37. }
  38. break;
  39. }
  40.  
  41. default:
  42. printf("not defined");
  43. break;
  44. }
  45. }
  46.  
Success #stdin #stdout 0s 5328KB
stdin
4 3 4
stdout
4 ÷ 3 = 1 ... 1