I previously made a program that just generates two random numbers, and the user must add them together and they get a point. I got a loop to work so that it made 10 questions and it would output their score out of how many questions they had thus far. However I want to take it to the next level and add a switch() so I can randomly generate an operand for the questions. (I'm pretty sure switch is the best way to do that)
My guess would be that on line 65, 69, and 74 where the "+" is. Is where I would put the "switch"? but I don't know how to do that :( ...it does run for the record.
A few of the problems I'm having is that:
1. It doesn't output their score every time. Only every two questions.
2. It only switches between addition and subtraction no matter how many times you've tried it.
3. On line 78 I used to have it say cout << "Your score is: " << score << " out of" << counter << " . " << endl <<endl;
However this threw an error about not recognizing "counter".
a switch is essentially (not taking in things like speed in to consideration merely its effect) a (imo) simplified if with the major problem of you cant switch strings. so you declare a switch with the variable to be "switched" in the paranthenses. the case is the condition, so case 1: would be like saying if(int == 1). you have to have a break after every case except default. default is the equivalent to an else
@DTScode ok thanks.
hmm ok I'm reading this better just a few questions about it:
What is the enum?
How does the char const * opStr = work? Like what is that?
and what is the std: : cout<<? why do you need std::?