Advertisement
Guest User

Switch

a guest
Oct 26th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     float num1, num2, soma, subtracao, multiplicacao, divisao;
  7.     int op;
  8.     // Operações : 1 á 4
  9.  
  10.     do {
  11.  
  12.     num1 = num2 = 0;
  13.  
  14.     printf(" (1) Somar\n");
  15.     printf(" (2) Subtrair\n");
  16.     printf(" (3) Multiplicar\n");
  17.     printf(" (4) Dividir\n");
  18.  
  19.     printf("Informe a operação: \n");
  20.     scanf("%i", &op);
  21.  
  22.     printf("Escolha o primeiro numero: \n");
  23.     scanf("%f", &num1);
  24.  
  25.     printf("Informe a operação: \n");
  26.     scanf("%f", &num2);
  27.  
  28.     float soma = num1 + num2;
  29.     float subtracao = num1 - num2;
  30.     float multiplicacao = num1 * num2;
  31.     float divisao = num1 / num2;
  32.  
  33.     switch(op) {
  34.  
  35. case 1:
  36.  
  37.     printf("O valor da soma e: %f\n", soma);
  38.     break;
  39.  
  40. case 2:
  41.     printf("O valor da subtracao e: %f\n", subtracao);
  42.     break;
  43.  
  44. case 3:
  45.     printf("O valor da multiplicacao e: %f\n", subtracao);
  46.     break;
  47. case 4:
  48.     printf("O valor da divisao e: %f\n", divisao);
  49.     break;
  50.  
  51.     default:("Digite uma opcao valida\n")
  52.  
  53.  
  54.     }
  55.  
  56.  
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement