RICDONTSTOP Posted December 9, 2002 Share Posted December 9, 2002 I need help on making a program where the program will ask the user a number of random maths questions, for example 4*4 = the program will only ask another question if there is a correct answer for the previous question. Please Help Richard Link to comment Share on other sites More sharing options...
0 xWeston Posted December 9, 2002 Share Posted December 9, 2002 do the questions have to be different every time? (actually random?) an easy way to do it would be with a large switch statement. Have a random # generated and then mod it by however many questions you have. Make this number go to a specific case (the same #) in the switch statement. Each switch statement will have a question with an answer tested. If it is right then it will go back to a random #, if it gets it wrong it will end. pretty basic Link to comment Share on other sites More sharing options...
0 CdCViRus Posted December 9, 2002 Share Posted December 9, 2002 A simpler way, IMO, would be: #include <iostream> #include <***.h> // *** is the lib where razdomize(), random () are defined int main () { randomize(); while (1) { make a question(); cout<<question; cin>>user_ans; if (user_ans!=correct_ans) break; // else another iteration of the while loop } return 0; } Link to comment Share on other sites More sharing options...
0 xWeston Posted December 10, 2002 Share Posted December 10, 2002 its basically the same idea, except "make a question ()" is pretty ambiguous, which i explained how to do in more detail. Link to comment Share on other sites More sharing options...
Question
RICDONTSTOP
I need help on making a program where the program will ask the user a number of random maths questions, for example 4*4 =
the program will only ask another question if there is a correct answer for the previous question.
Please Help
Richard
Link to comment
Share on other sites
3 answers to this question
Recommended Posts