The part of my program I am working on is supposed to give the user random multiplication problems, the user gives an answer, then the program says correct or incorrect. 2 Questions
1. How do I check to get the real answer?
2. If it is incorrect I have to let them retry the same problem up to 3 times. Since I am using a random # generator in a separate function I don't know how to make the exact same problem keep coming up.
This is what I have so far but I get an error
non-lvalue in assignment
what does this mean?
for(i=1;i%26lt;=PROBLEMS;i++)
{
num1=randIntBetween(minNum, maxNum);
num2=randIntBetween(2, maxNum);
cout%26lt;%26lt;i%26lt;%26lt;")"%26lt;%26lt;num1%26lt;%26lt;"x"%26lt;%26lt;num2%26lt;%26lt;"=";
cin%26gt;%26gt;stuAnswer;
num1 * num2 = trueAnswer;
if (stuAnswer == trueAnswer)
{cout%26lt;%26lt;"Correct!";
numRight++;
}
C++ program how to check a math problem?
First, change num1 * num2 = trueAnswer;
to:
trueAnswer = num1 * num2;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment