How can you force the a program to only pick numbers that are divisible to an integer?
This way for instance you don't generate 5/12 and 0 is the correct answer. I'm assuming you could use an if else statement so that if the answer doesn't equal an int it picks to different numbers but how would you set that up since you can't make something likeCode:for (pro = 0; pro < numpro; pro++) //keeps a count until number of problems desired is reached { srand((unsigned)time(0)); // allows for random number generation num1 = rand(); num1 = rand() % 12 + 1; num2 = rand(); // picks a second random number that will not be the first num2 = rand() % 12 + 1; cout << "\n\n " << num1 << " / " << num2 << " = " ; cin >> ansr; total = num1/num2; { if (total == ansr) // verifies input answer is correct { right++; cout << "\n Correct!" << endl; } else if (total != ansr) { wrong++; cout << "\n Incorrect. The correct answer is: " << total << endl; } }
because int isn't really something assigned right?Code:if (num1 + num2 = int) cin >> ansr; else if (num1 + num2 !=int) srand((unsigned)time(0)); num1 = rand(); num1 = rand() % 12 + 1; num2 = rand();