simple calculator

#include <iostream>
#include <cmath>

using namespace std;


int main()
{
int a;
int n1;
int n2;

cout << "enter operator: " << endl;
cin >> a;

cout << "enter first number: " << endl;
cin >> n1;

cout << "enter second number: " << endl;
cin >> n2;

switch( a )
{
case '+' :
cout << n1 << " + " << n2 << " = " << n1 + n2 << endl;
break;

case '-' :
cout << n1 << " - " << n2 << " = " << n1 - n2 << endl;
break;


case '*' :
cout << n1 << " x " << n2 << " = " << n1 * n2 << endl;
break;


case '/' :
cout << n1 << " / " << n2 << " = " << n1 / n2 << endl;
break;
}

return 0;
}
int a;
should be
char a;
instead.
Topic archived. No new replies allowed.