Untitled

mail@pastecode.io avatar
unknown
c_cpp
8 months ago
494 B
1
Indexable
Never
#include <iostream>
#include <cmath>
using namespace std;
double asd(char c, double a, double b)
{
	switch(c)
	{
		case '+':
			return a + b;
			break;
		case '-':
			return a - b;
			break;
		case '*':
			return a * b;
			break;
		case '/':
			return a / b;
			break;
		case '^':
			return pow(a, b);
			break;
		default:
			cout << "error" << endl;
			return 0;
			break;
	}
}
int main()
{
	double a, b;
	char c;
	cin >> a >> c >> b;
	cout << asd(c, a, b);
}
Leave a Comment