-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathquiz.cpp
More file actions
106 lines (95 loc) · 3.32 KB
/
quiz.cpp
File metadata and controls
106 lines (95 loc) · 3.32 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
string questions[10] = {
"Which of the following is Tricontinental Country?",
"Famous fast food restaurant company Burger King belongs to which Country?",
"Office of strategic service (OSS) was old name of which Intelligence agency?",
"The first person to draw the map of earth?",
"Who laid first step on the Moon?",
"What is the name of Chinese parliament?",
"Ogaden desert is present in__________?",
"Capital of America is___________?",
"Wadi Rum which resemblance to the surface of Mars is located in__________?",
"Borneo Island is in which Ocean?"
};
string options[10][4] = {
{"chad","Chile","Mali","Swaziland"},
{"America","England","Turkey","None of these"},
{"MI6","CIA","ISI","N.O.T"},
{"Heraclitus","phythagoras","Anaximander","Thales"},
{"LMP Edgar","CMP Stuart","Neil Armstrong","None of them"},
{"National Assembly","National people’s Congress","Fedral parliament","None"},
{"Europe","Asia","Africa","America"},
{"Washington Dc","Alaska","Hawaii","California"},
{"Argentina","Israel","Jordan","Egypt"},
{"Indian Ocean","Pacific Ocean","Arctic Ocean","Atlantic"},
};
string correctOptions[10] = {
"Chile","America","CIA","Anaximander",
"Neil Armstrong","National people’s Congress","Africa",
"Washington DC","Jordan","Pacific Ocean"
};
int userOptions[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int totalQs = 10;
int op;
//----- Conducting Quiz -----
for( int i=0; i<totalQs; i++ ){
cout<<"Question # "<<(i+1)<<endl;
cout<< questions[i]<<endl;
cout<< "1."<<options[i][0]<<endl;
cout<< "2."<<options[i][1]<<endl;
cout<< "3."<<options[i][2]<<endl;
cout<< "4."<<options[i][3]<<endl<<endl;
cout<<"Select Option (1-4) or 0 to skip and press enter: ";
cin >> userOptions[i];
cout<<endl<<"-----------------------------"<<endl<<endl;
}
//----- Printing Correct Options -----
cout<<"======= ======= ======= ======= "<<endl;
cout<<"======= Correct Options ======= "<<endl;
cout<<"======= ======= ======= ======= "<<endl;
for( int i=0; i<totalQs; i++ ){
cout<<"Question # "<<(i+1)<<endl;
cout<< questions[i]<<endl;
cout<< "1."<<options[i][0]<<endl;
cout<< "2."<<options[i][1]<<endl;
cout<< "3."<<options[i][2]<<endl;
cout<< "4."<<options[i][3]<<endl;
if( userOptions[i] == 0 ){
cout<< "You Skipped this Question."<<endl;
}else{
cout<< "You Selected : "<<options[i][userOptions[i]-1]<<endl;
}
cout<< "Correct Option : "<<correctOptions[i]<<endl<<endl;
cout<<"Press any key to continue..."<<endl;
getch();
cout<<endl<<"------------------"<<endl;
}
//----- Printing Result -----
cout<<endl<<endl;
cout<<"======= ======= ======= ======= "<<endl;
cout<<"======= Result ======= "<<endl;
cout<<"======= ======= ======= ======= "<<endl;
int correct = 0;
int incorrect = 0;
int skipped = 0;
for( int i=0; i<totalQs; i++ ){
if( userOptions[i] != 0 ){
if( correctOptions[i] == options[i][userOptions[i]-1] ){
correct++;
}else{
incorrect++;
}
}else{
skipped++;
}
}
cout<< "Total Questions : "<< totalQs <<endl;
cout<< "Correct : "<< correct <<endl;
cout<< "In-Correct : "<< incorrect <<endl;
cout<< "Skipped : "<< skipped <<endl;
getch();
return 0;
}