Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int leNumeroInteiro();
- float leNumeroDecimal();
- int main()
- {
- printf("Informe a operacao:\n");
- printf("1. Divisao\n");
- printf("2. Adicao\n");
- printf("3. Subtracao\n");
- printf("4. Multiplicacao\n");
- printf("0. Sair\n");
- int opcao = leNumeroInteiro();
- if(opcao != 0)
- {
- float valor1;
- printf("Digite o valor 1\n");
- valor1 = leNumeroDecimal();
- float valor2;
- printf("Digite o valor 2\n");
- valor2 = leNumeroDecimal();
- float resultado;
- switch(opcao) {
- case 1:
- resultado = valor1 / valor2;
- break;
- case 2:
- resultado = valor1 + valor2;
- break;
- case 3:
- resultado = valor1 - valor2;
- break;
- case 4:
- resultado = valor1 * valor2;
- break;
- }
- printf("Resultado: %f\n", resultado);
- system("pause");
- }
- return 0;
- }
- int leNumeroInteiro() {
- int retValue;
- scanf("%d", &retValue);
- return retValue;
- }
- float leNumeroDecimal() {
- float retValue;
- scanf("%f", &retValue);
- return retValue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement