Ok, great. The problem is I only know how to get input with cin. So I wouldn't have to make a lot of variables, or? How do I know how many variables to make?
Type: Posts; User: grache28
Ok, great. The problem is I only know how to get input with cin. So I wouldn't have to make a lot of variables, or? How do I know how many variables to make?
What if I don't need the calculator to perform the correct order of operations, for example:
5-3*5
=10
It just reads from left to right, but the amount of operators and operands is unknown. So...
Ok, thanks to you both. I'll work out a way to do it with the Shunting-yard algorithm and come back if I have any problems.
Thanks, that looks like a good way of doing it, but probably a little more advanced than what I need. Theres no other way to adjust for multiple operators and operands?
Ok I got it working via a swtich that does this:
std::cin>> op1 >> opr >> op2;
switch(opr){
case '+':
std::cout << op1+op2 << "\n";
break;
doh *facepalm*
Thanks
I'm trying to make a simple calculator, but it has to receive input like this:
operand-operator-operand
i.e.
6*5
76+2
670/10
I've got to take an exam in a few days, and I've been studying exams from other years and theres one that is giving me a little trouble. I have an idea about how to write the code, but I think there...