1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <iostream>
#include <conio.h> // for getch
#include <ctype.h> // for toupper
using namespace std;
char Questions[10][200] = { // 200 chars for question length should cover it :)
"1. Hitler party which came into power in 1933 is known as\na) Labour Party b) Nazi Party c) Ku-Klux-Klan d) Democratic Party\n\n",
"2. 9/11 Happened in which major USA city?\na) Los Angeles b) Chicago c) New York d) Boston\n\n",
"3. In our solar system, which planet comes after Saturn?\na) Venus b) Mars c) Uranus d) Pluto\n\n",
"4. What is the capital city of Australia?\na) Camberra b) Sydney c) Perth d) Melbourne\n\n",
"5. What is the most spoken language in the World?\na) Spanish b) English c) Chinese d) Mandarin\n\n",
"6. Who won the world cup in 1966?\na) England b) Brazil c) Spain d) Italy\n\n",
"7. The largest mountain in the UK is:\na) Snowdon b) Tryfan c) Ben Nevis d) Skiddaw\n\n",
"8. What is the currency used in Japan?\na) Euro b) Yen c) Dollar d) Rupee\n\n",
"9. Who is the current CEO of Microsoft?\na) Satya Nadella b) Bill Gates c) Indra Nooyi d) Adam Arnold\n\n",
"10. When was the Berlin Wall knocked down?\na) 1989 b) 1967 c) 1985 d) 1991\n\n"
};
char Answers[10] = { 'B', 'C', 'C', 'A', 'D', 'A', 'C', 'B', 'A', 'A' };
int score;
int main()
{
score = 0;
char myAns;
// loop through the 10 questions 1 by 1
for (int qNum = 0; qNum < 10; qNum++) {
// show the question using the array and index
cout << Questions[qNum];
cout << "Enter Answer (A-D): ";
// keep reading the keyboard unless we get a A to D keypress
do {
myAns = _getch();
myAns = toupper(myAns);
} while (myAns < 'A' || myAns > 'D');
// display what i pressed.
cout << myAns << endl;
// we use the index of Questions to grab the correct answer from the
// answers array.
if (myAns == Answers[qNum]) {
cout << "Well done you got it correct!"<<endl<<endl;
score++;
}
else
cout << "Unlucky, the answer was " << Answers[qNum]<<endl<<endl;
}
// display our score.
cout << endl << "You scored " << score << " out of a possible 10.";
return 0;
}
|