#include <iostream>
#include <string>
#include <algorithm>
usingnamespace std;
int a;
int b;
int answer;
char z;
int main(){
cout<<"Please type an operation... +,-,*,/."<<endl;
cin>>z;
cout<<"Please enter your first number"<<endl;
cin>>a;
cout<<"Please enter your second number"<<endl;
cin>>b;
cout<<"\n\n"<<endl;
char operation = a+z+b;
answer = operation;
cout<<a<<z<<b<<"="<<answer<<endl;
system("pause");
return 0;
}
char operation is a character variable. A char variable can hold data of type char. If you want a string, you can either declare a string variable or use a char array. But I believe you're trying to add the integer variables a and b.
One way to do this would be to use a series of if-else statements that perform an operation based on the operator (in your case, z). Since z happens to be a single character, you can check equivalence and assign an appropriate result based on the operation to be done.
@ENIGMAx
i think a switch statement would give a better readability of the program.
you're actually comparing one variable against several constants, that's the point of switch after all, if you don't use it here, they shouldn't have included it in the standard in the first place.