1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
double Sumar(double,double);
double Restar(double,double);
double Multiplicar(double,double);
double Dividir(double,double);
int main()
{
cout << "Calculadora" << endl;
double val1;
cout << "Introduce el primer valor: ";
cin >> val1;
double val2;
cout << "Introduce el segundo valor: ";
cin >> val2;
int operador;
cout << "Le gustaria Sumar (1), Restar (2), Multiplicar (3), Dividir (4) o Salir (5)?: ";
cin >> operador;
switch(operador)
{
case 1:
cout << "\n";
cout << Sumar(val1,val2) << endl;
cout << "\n";
break;
case 2:
cout << "\n";
cout << Restar(val1,val2) << endl;
cout << "\n";
break;
case 3:
cout << "\n";
cout << Multiplicar(val1,val2) << endl;
cout << "\n";
break;
case 4:
cout << "\n";
cout << Dividir(val1,val2) << endl;
cout << "\n";
break;
}
return 0;
}
double Sumar(double x,double y)
{
return x + y;
}
double Restar(double x,double y)
{
return x - y;
}
double Multiplicar(double x,double y)
{
return x * y;
}
double Dividir(double x,double y)
{
return x / y;
}
|