#include <iostream>
#include <cmath>
using namespace std;
double suma(double a, double b);
double atimtis(double a, double b);
double daugyba(double a, double b);
double dalyba(double a, double b);
double laipsnis(double a, double b);
void atsakymas(double a, char veiksmas, double b);
int main()
{
char veiksmas;
double a;
double b;
cout << "Iveskite kintamaji a" << endl;
cin >> a;
cout << "Iveskite norima veiksmas (+,-,/,*, ^)" << endl;
cin >> veiksmas;
cout << "Iveskite kintamaji b" << endl;
cin >> b;
atsakymas(a, veiksmas, b);
return 0;
}
void atsakymas(double a, char veiksmas, double b)
{
if (veiksmas == '+'){
cout << a << " + " << b << " = " << suma(a, b) << endl;
}
else
if (veiksmas == '-'){
cout << a << " - " << b << " = " << atimtis(a, b) << endl;
}
else
if (veiksmas == '*'){
cout << a << " * " << b << " = " << daugyba(a, b) << endl;
}
else
if (veiksmas == '/' && b != 0){
cout << a << " / " << b << " = " << dalyba(a, b) << endl;
}
else
if (veiksmas == '^'){
cout << a << " ^ " << b << " = " << laipsnis(a, b) << endl;
}
else
cout << "Tokio veiksmo atlikti negalime" << endl;
}
double suma(double a, double b)
{
return a + b;
}
double atimtis(double a, double b)
{
return a - b;
}
double daugyba(double a, double b)
{
return a * b;
}
double dalyba(double a, double b)
{
return a / b;
}
double laipsnis(double a, double b)
{
return pow(a, b);
}