Hi, sorry, this is Part 2 of a similar assignment. But there's a couple things I don't understand and Google isn't really helping me and my teacher is the very dictionary term of unreliable. Before I continue, here's the code:
cout << "Enter the operand (+, -, *, or /): " << endl;
cin >> op;
while (op == '+' || op == '-' || op == '*' || op == '/')
{
acc = accumulate2(acc, num, op);
cout << "\nAccumulated value is now: " << acc << endl;
cout << "\n";
cout << "Enter the operand (+, -, *, or /): " << endl;
cin >> op;
}
}
As with my last one, the end result should be:
0
+ 1 = 1
* 5 = 5
- 3 = 2
+ 7 = 9
etc.
The assignment requires me to use "acc = accumulate2(acc, num, op);" (Which I don't understand the logic of.) and "double accumulate2(double acc, double num, char op)" call on top. As the code stands, every entry is nan, which I know means not a number.
So my question to you all is:
How is this nan being formed and how can I correct it.
Also, so I actually understand why I'm being forced to write it this way, can someone explain the significance of the double specifically being a call instead of a void or whatever as well as why my accumulator needs to be equal to my call?
I really appreciate it! I learn a lot more here than in class!