#include<iostream.h> void scoreQuestion1(char cAnswer); void scoreQuestion2(char cAnswer); void scoreQuestion3(char cAnswer); void scoreQuestion4(char cAnswer); void scoreQuestion5(char cAnswer); char arUserAnswers[5]; char arCorrectAnswers[5]={'d','a','d','c','b'}; void recordAnswer(int iQuestion,char cAnswer) { arUserAnswers[iQuestion-1]= cAnswer; } void scoreQuiz() { int iTotalCorrect=0; for(int ctCount=0;ctCount<5;++ctCount) { if(arUserAnswers[ctCount] ==arCorrectAnswers[ctCount]) ++iTotalCorrect; } cout<< "You ANSWERED " << iTotalCorrect << " out of 5 QUESTIONS correctly!"<<endl; } void main(){ char cInput; cout<<"quiz\n"; //question 1 cout<< "1. Who is the Former Secretary"<< endl << " General of United Nations?"<< endl <<"\ta.Mr.George Bush"<<endl <<"\tb.Mr.Jimmy Carter"<<endl <<"\tc.Mr.Ban Kin Moon"<<endl <<"\td.Mr.Kofi Annan"<<endl; cout<< "Your answer>"; cin>>cInput; recordAnswer(1,cInput); //question 2 cout<< "2. Where does he come from?"<< endl <<"\ta.Ghana"<<endl <<"\tb.USA"<<endl <<"\tc.Mali"<<endl <<"\td.Canada"<<endl; cout<< "Your answer>"; cin>>cInput; recordAnswer(2,cInput); //question 3 cout<< "3.The Headquaters of the United Nations"<< endl << " is situated in which Country"<< endl <<"\ta.Tokyo-Japan"<<endl <<"\tb.Oslo-Norway"<<endl <<"\tc.Accra-Ghana"<<endl <<"\td.NewYork-USA"<<endl; cout<< "Your answer>"; cin>>cInput; recordAnswer(3,cInput); //question 4 cout<< "4. Who is the current Secretary General"<< endl << " of United Nations?"<< endl <<"\ta.Ms.Sarah Pollin"<<endl <<"\tb.Mr.Botros Botros Ghali"<<endl <<"\tc.Mr.Ban Kin Moon"<<endl <<"\td.Mr.Kofi Annan"<<endl; cout<< "Your answer>"; cin>>cInput; recordAnswer(4,cInput); //question 5 cout<< "5. Where does he come from?"<< endl <<"\ta.Ghana"<<endl <<"\tb.South Korea"<<endl <<"\tc.Ireland"<<endl <<"\td.Egypt"<<endl; cout<< "Your answer>"; cin>>cInput; recordAnswer(5,cInput); scoreQuiz(); cout<<endl; } void scoreQuestion1(char cAnswer){ if(cAnswer=='a') cout<<"Incorrect Answer"<<endl; if(cAnswer=='b') cout<<"Incorrect Answer"<<endl; if(cAnswer=='c') cout<<"Incorrect Answer"<<endl; if(cAnswer=='d') cout<<"Correct Answer"<<endl; } void scoreQuestion2(char cAnswer){ if(cAnswer=='a') cout<<"Correct Answer"<<endl; if(cAnswer=='b') cout<<"Incorrect Answer"<<endl; if(cAnswer=='c') cout<<"Incorrect Answer"<<endl; if(cAnswer=='d') cout<<"Incorrect Answer"<<endl; } void scoreQuestion3(char cAnswer){ if(cAnswer=='a') cout<<"Incorrect Answer"<<endl; if(cAnswer=='b') cout<<"Incorrect Answer"<<endl; if(cAnswer=='c') cout<<"Incorrect Answer"<<endl; if(cAnswer=='d') cout<<"Correct Answer"<<endl; } void scoreQuestion4(char cAnswer){ if(cAnswer=='a') cout<<"Incorrect Answer"<<endl; if(cAnswer=='b') cout<<"Incorrect Answer"<<endl; if(cAnswer=='c') cout<<"Correct Answer"<<endl; if(cAnswer=='d') cout<<"Incorrect Answer"<<endl; } void scoreQuestion5(char cAnswer){ if(cAnswer=='a') cout<<"Incorrect Answer"<<endl; if(cAnswer=='b') cout<<"Correct Answer"<<endl; if(cAnswer=='c') cout<<"Incorrect Answer"<<endl; if(cAnswer=='d') cout<<"Incorrect Answer"<<endl; }
//#include<iostream.h> #include<iostream> using namespace std;
_T("Welcome")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)