#include <iostream>
using namespace std;
void menu();
void leerNumeros(float &x, float &y);
float suma(float x, float y);
float resta(float x, float y);
int main()
{
float a, b;
char opcion;
do {
menu();
cin >> opcion;
switch (opcion)
{
case '1':
leerNumeros(a, b);
cout << endl << a << " + " << b << " = " << suma(a, b) << endl;
break;
case '2':
leerNumeros(a, b);
cout << endl << a << " - " << b << " = " << resta(a, b) << endl;
break;
case '3':
cout << "\n\nFIN DEL PROGRAMA" << endl;
break;
default:
cout << "\n\nOPCION NO VALIDA" << endl;
break;
}
} while (opcion != '3');
return 0;
}
void menu()
{
cout << "\n OPERACION"
<< "\n====================="
<< "\n1.- Suma"
<< "\n2.- Resta"
<< "\n3.- Salir"
<< "\n====================="
<< "\nOPCION (1-3): ";
}
void leerNumeros(float &x, float &y)
{
cout << "\nPrimer numero: "; cin >> x;
cout << "Segundo numero: "; cin >> y;
}
float suma(float x, float y)
{
return x + y;
}
float resta(float x, float y)
{
return x - y;
}