Question

Create a simple c++ console GUI application, any kind of quiz with multiple choice answers.

Create a simple c++ console GUI application, any kind of quiz with multiple choice answers.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream.h>
#include<conio.h>
#include<string.h>

int main(){

//array of question
char que[5][100]={"What is the Capital of India?","What is the name of the President of USA?","What is the name of the Prime Minister of India?","Who invented the law of motions?","Who is the CEO of microsoft?"};

//array of corresponding answers to the questions
char ans[5]={'D','B','A','C','D'};

//options for each question
char options[5][4][50]={"A. Mumbai","B. Ahmedabad","C. Chennai","D. Delhi","A. Barak Obama","B. Donald Trump","C. Hillary","D. Steve","A. Narendra Modi","B. Manmohansinh","C. Pranav Mukherjee","D. Morarjee Desai","A. Einstein","B. Galaliyo","C. Isacc Newton","D. Rutherford","A. Steve Jobs","B. Tim Cook","C. Larry Page","D. Bill Gates"};

//answer enterd by the user
char response[5];

//final score
int score=0;
clrscr();

for(int i=0;i<5;i++)
{   
   //print question
       cout<<que[i]<<endl;
      
       //print 4 options
       cout<<options[i][0]<<"\t"<<options[i][1]<<endl;
       cout<<options[i][2]<<"\t"<<options[i][3]<<endl;
      
       //read response from user
       response[i]=getch();

}

for(int i=0;i<5;i++){

//match user response with correct answer
//if correct the increment the score.
if(ans[i]==response[i])
score++;

}
//print the score.
cout<<"Your Result is: "<<score;
getch();
return 0;
}

Output:
DOSBox 0.74, Cpu speed: max 100% cycles, Frameskip 0, Program: What is the Capital of India? A. Mumba i C. Chenmai TC B. Ahme

Add a comment
Know the answer?
Add Answer to:
Create a simple c++ console GUI application, any kind of quiz with multiple choice answers.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT