-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS Quiz.cpp
More file actions
160 lines (118 loc) · 5.1 KB
/
OOPS Quiz.cpp
File metadata and controls
160 lines (118 loc) · 5.1 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include<iostream>
#include<string>
using namespace std;
char choice;
int total_marks;
class Questions
{
private:
string question;
string option1;
string option2;
string option3;
string option4;
char correct_answer;
char correct_answer1;
int marks;
public:
void input (string,string,string,string,string,char,char,int);
void display();
};
int main()
{
cout<<"-------------------------------------------------------\n";
cout<<"*******************************************************\n";
cout<<"* *\n";
cout<<"* * WELCOME TO OOPS QUIZ! * *\n";
cout<<"* *\n";
cout<<"* _______________________________ *\n";
cout<<"* By: *\n";
cout<<"* *\n";
cout<<"* Charu (CO19319) *\n";
cout<<"* Harshdeep Singh Mand (CO19325) *\n";
cout<<"* Taruna Saini (CO19366) *\n";
cout<<"* *\n";
cout<<"*******************************************************\n";
cout<<"-------------------------------------------------------\n";
cout<<"Prass enter to start the quiz.......";
cin.get();
cout<<"GOOD LUCK! Each Question is of 10 Marks for a total of 100 Marks.";
Questions q1;
Questions q2;
Questions q3;
Questions q4;
Questions q5;
Questions q6;
Questions q7;
Questions q8;
Questions q9;
Questions q10;
q1.input("The pointers which are not initialized in a program are called:", "Void pointers", "Generic pointers", "Null pointers", "Empty pointers",'C','c', 10);
q2.input("A function declared in a base class that has no definition relative to the base class:", "Base function", "Pure Virtual Function", "Virtual function", "Member function",'B','b', 10);
q3.input("ios::in for ifstrem functions means:", "Open for writng only", "Append to end of file ", "Binary file", "Open for reading only",'D','d', 10);
q4.input("The default visibility mode of a class is: ", "Public", "Private", "Protected", "None of the above",'B','b', 10);
q5.input("The smallest individual unit in a program is called: ", "Token", "Objects", "Data", "Class",'A','a', 10);
q6.input("The operators that are used to format the data display are: ", "Member derferencing operators", "Memory management operators", "Manipulators", "Type cast operators",'C','c', 10);
q7.input("The code for handling exceptions isn included in: ", "Try block", "Catch block", "Throw statement", "None of the above",'B','b', 10);
q8.input("How many file pointers are associated with each file?", "One", "Two", "Four", "Six",'B','b', 10);
q9.input("Which of the following statements is true? ", "Virtual functions can be static members", "We can have virtual constructors", "We cannot have destructors", "A virtual function can be a friend of another class",'C','c', 10);
q10.input("A class is called polymorphic if it contains: ", "Friend Function ", "Inline function", "Main function", "Virtual function",'D','d', 10);
q1.display();
q2.display();
q3.display();
q4.display();
q5.display();
q6.display();
q7.display();
q8.display();
q9.display();
q10.display();
cout<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
cout<<"$ $\n";
cout<<"$ CONGRATULATIONS! $\n";
cout<<"$ YOU COMPLETED THE QUIZ $\n";
cout<<"$ $\n";
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
cout<<endl<<"Your Total Score is: "<<total_marks <<" out of 100\n\n\n";
return 0;
}
void Questions::input(string q,string a1 ,string a2,string a3,string a4, char ans,char ans1, int i)
{
question = q;
option1 = a1;
option2 = a2;
option3 = a3;
option4 = a4;
correct_answer = ans;
correct_answer1 = ans1;
marks = i;
}
void Questions::display()
{
cout<<endl;
cout<<question<<endl;
cout<<"A. "<<option1<<endl;
cout<<"B. "<<option2<<endl;
cout<<"C. "<<option3<<endl;
cout<<"D. "<<option4<<endl;
cout<<endl;
cout<<"Choose an option: ";
cin>>choice;
if(choice==correct_answer||choice==correct_answer1)
{
cout<<endl;
cout<<"Absolutely Correct! \n";
total_marks = total_marks + marks;
cout<<"You earned "<<marks<<"marks.\n";
cout<<"New total = "<<total_marks;
cout<<endl;
}
else
{
cout<<endl;
cout<<"Sorry, Wrong Answer! You need to study some more..";
cout<<"The Correct Answer is: "<<correct_answer;
cout<<endl;
}
}