Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     float v1, v2, res;
  7.     int opc;
  8.    
  9.     printf("!#########!\n");
  10.     printf("Calculadora\n");
  11.     printf("!#########!\n\n");
  12.     printf("Digite o primeiro número: \n");
  13.     scanf("%f",&v1);
  14.     printf("\nDigite o segundo número: \n");
  15.     scanf("%f",&v2);
  16.     printf("\nO que você deseja fazer:\n");
  17.     printf("1 - Somar\n2 - Subtrair\n3 - Multiplicar\n3 - Multiplicar\n4 - Dividir\n\n");
  18.     scanf("%d",&opc);
  19.    
  20.         switch(opc)
  21.         {
  22.             case 1:
  23.                 res = v1+v2;
  24.                 printf("Resultado: %.0f\n", res);
  25.                 break;
  26.             case 2:
  27.                 res = v1-v2;
  28.                 printf("Resultado: %.0f\n", res);
  29.                 break;
  30.             case 3:
  31.                 res = v1*v2;
  32.                 printf("Resultado: %.0f\n", res);
  33.                 break;
  34.             case 4:
  35.                 res = v1/v2;
  36.                 printf("Resultado: %f\n", res);
  37.                 break;
  38.             default:
  39.                 printf("Opção inválida!\n");
  40.                 break;
  41.         }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement