fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. char operacao;
  6. printf("Escolha a opecaracao que deseja realizar: ");
  7. scanf("%c", &operacao);
  8. switch (operacao) {
  9. case '+': {
  10. int n1, n2;
  11. printf("\nInsira N1: "); scanf("%d", &n1);
  12. printf("\nInsira N2: "); scanf("%d", &n2);
  13. printf("\n%d + %d = %d", n1, n2, n1 + n2);
  14. break;
  15. } case '-': {
  16. int n1, n2;
  17. printf("\n Insira N1: "); scanf("%d", &n1);
  18. printf("\n Insira N2: "); scanf("%d", &n2);
  19. printf("\n %d - %d = %d", n1, n2, n1 - n2);
  20. break;
  21. } case '*': {
  22. int n1, n2;
  23. printf("\n Insira N1: "); scanf("%d", &n1);
  24. printf("\n Insira N2: "); scanf("%d", &n2);
  25. printf("\n %d X %d = %d", n1, n2, n1 * n2);
  26. break;
  27. } case '/': {
  28. int n1, n2;
  29. printf("\n Insira N1: "); scanf("%d", &n1);
  30. printf("\n Insira N2: "); scanf("%d", &n2);
  31. printf("\n %d / %d = %.2f", n1, n2, (float)n1 / n2);
  32. break;
  33. }
  34. }
  35. }
  36.  
  37. //https://pt.stackoverflow.com/q/332677/101
Success #stdin #stdout 0s 9424KB
stdin
/
5
2
stdout
Escolha a opecaracao que deseja realizar: 
 Insira N1: 
 Insira N2: 
 5 / 2 = 2.50