Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- float v1, v2, res;
- int opc;
- printf("!#########!\n");
- printf("Calculadora\n");
- printf("!#########!\n\n");
- printf("Digite o primeiro número: \n");
- scanf("%f",&v1);
- printf("\nDigite o segundo número: \n");
- scanf("%f",&v2);
- printf("\nO que você deseja fazer:\n");
- printf("1 - Somar\n2 - Subtrair\n3 - Multiplicar\n3 - Multiplicar\n4 - Dividir\n\n");
- scanf("%d",&opc);
- switch(opc)
- {
- case 1:
- res = v1+v2;
- printf("Resultado: %.0f\n", res);
- break;
- case 2:
- res = v1-v2;
- printf("Resultado: %.0f\n", res);
- break;
- case 3:
- res = v1*v2;
- printf("Resultado: %.0f\n", res);
- break;
- case 4:
- res = v1/v2;
- printf("Resultado: %f\n", res);
- break;
- default:
- printf("Opção inválida!\n");
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement