Jump to content
  • Advertisement
Sign in to follow this  

trivia game help

This topic is 5451 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i need a trivia game in this format i need to use structs...now how do i store which answer is correct.and randomize the answers so the player cannot remember all the ansers ///////////////////////////////////////////// QUESTION #1: In Fourteen Hundred Ninety-Two, Columbus sailed ____________. 1) a kangaroo 2) the ocean blue 3) to Timbuktu 4) in a canoe If the user answered 2: "You are correct!" If the user answered 1, 3 or 4: "Sorry. The correct answer was 'the ocean blue'!" ///////////////////////////////////////////// the second time theprogram is run it would look like this In Fourteen Hundred Ninety-Two, Columbus sailed ____________. 1) in a canoe 2) to Timbuktu 3) a kangaroo 4) the ocean blue /////////////////////////////////////////////
typedef struct 
    char chquestion[255];
	char answera[255];
	char answerb[255];
	char answerc[255];
	char answerd[255];
	bool isanswer;
} question; 
question List[] = 
// thes are not the questions just trying to prototype the program
        {"what is 2+2","4","b" ,"c" ,"d"}, 
        {"what is 2+6","8","b" ,"c" ,"d"}, 
        {"what is 2+8","10","b" ,"c" ,"d"}, 
        {"what is 2+10","12","b" ,"c" ,"d"},
		{"what is 2+12","14","b" ,"c" ,"d"}, 
        {"what is 2+16","18","b" ,"c" ,"d"}, 
        {"what is 2+18","20","b" ,"c" ,"d"}, 
        {"what is 2+20","22","b" ,"c" ,"d"}, 
		{"what is 2+22","24","b" ,"c" ,"d"}, 
        {"what is 2+26","28","b" ,"c" ,"d"}, 
        {"what is 2+28","30","b" ,"c" ,"d"}, 

Share this post

Link to post
Share on other sites
umm ggenerate a list of answers???
i am not understanding exactly what u mean..................

((the list[] in my code is the questions with the answers.)just wanted to point that out);

but here is the whole story i am beta testing an assignment for a site........... and this is what he wants me to do


You will present the user with a series of ten multiple choice questions, each with one correct answer and three incorrect ones.

For each question, the user will select their answer from a menu. You will tell them if they guessed correctly, or what the correct answer was if they guessed wrong.

After all the questions have been asked, tally up their score, and praise or insult their performance (as appropriate).

Now, you don't want to make it too easy for them. So, let's randomize what order the questions are asked in. And, within each question, let's also randomize the order of answers listed (keeping in mind that this also affects which answer is counted as correct).

You should be able to complete this assignment after working through the "structures" and "functions" lectures...


Share this post

Link to post
Share on other sites
option 1:
in the 'question' struct add:
int rightanswer;

if its 1 then answera is the right answer, if its 2 then answerb is the right, etc.
option 2:
if you do the list randomally, then you can do the first answer always the right answer. anyway the computer will re-set the list order.

generating a list = to do that the computer will create a list automatically (use rand() and srand() to generate randomally)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!