char variable question

i'm just messing with simple test code and i'm asking the user to input two integers and then one of four math functions, + - * /, and then am outputting the result. i defined the operator as a char type but i can't figure out how to get the function to work right. normally it's (a + b) but i'm trying to get (a char b) but i'm not coming up with the right syntax. any help? thank you!

You want to print the char?
1
2
3
4
int a = 4;
int b = 5;
char op = '+';
std::cout << a << op << b << std::endl;
i want to calculate the result based on the char operator that was input
In that case you will have to use if statements or a switch statement to check the char and cary out the correct operation.
i thought maybe there was a way to use the variable in the equation. thanks
Topic archived. No new replies allowed.