I am making a quiz show in C++

I need help in storing the answers of a quiz in a array

like

cout<<"Q.1 Who is Known as the lady with lamp ?"<<endl<<endl;
cout<<"A. Sonia Gandhi "<<"B. Florence Nightngle"<<endl;
cout<<"C. Mother Tersa "<<"D. Madame Rozario"<<endl<<endl<<endl;

So how do I Input the answers in a array ??? gets ??? I also need to compare it from an array of correct answers.

Recommended Answers

All 2 Replies

Perhaps a structure, say

struct question {
  std::string question;
  std::string answers[4];
  int correctAnswer;
};

Then later, you can say question quiz[10]; // 10 questions in this quiz Now see if you can write some code to
- initialise that array, say from a file
- print each question and possible answers in turn
- read a response from the user.

You can keep the question and answer in afile and read from it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.