-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiz project.cpp
217 lines (213 loc) · 4.99 KB
/
quiz project.cpp
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#include<iostream>
#include<conio.h>
#include<cstdlib>
#include<windows.h>
using namespace std;
struct student{
char nam[20],rollno[20];
int marks,random;
};
student st;
void cppp(){
int i=0,arr[6];
st.marks=0;
char choice;
while(i<5){
back:
st.random=rand()%6;
for(int j=0;j<=6;j++){
if(st.random==arr[j]){
goto back;
}
}
arr[i]=st.random;
switch(st.random)
{
case 0:
cout<<i+1<<") What is a correct syntax to output \"Hello World\" in C++?"<<endl;
cout<<"A. System.out.println(\"Hello world\");"<<endl;
cout<<"B. Console.WriteLine(\"Hello world\");"<<endl;
cout<<"C. print(\"Hello world\");"<<endl;
cout<<"D. cout<<\"Hello world\";"<<endl;
choice=getch();
if(choice=='D'||choice=='d'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl;
cout<<"The corrent answer is d"<<endl<<endl;
}
break;
case 1:
cout<<i+1<<") Which of the following is called address operator?"<<endl;
cout<<"a) *"<<endl;
cout<<"b) &"<<endl;
cout<<"c) _"<<endl;
cout<<"d) %"<<endl;
choice=getch();
if(choice=='B'||choice=='b'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl;
cout<<"The corrent answer is b"<<endl<<endl;
}
break;
case 2:
cout<<i+1<<") Which of the following is used for comments in C++?"<<endl;
cout<<"a) // comment"<<endl;
cout<<"b) /* comment */"<<endl;
cout<<"c) both // comment or /* comment */"<<endl;
cout<<"d) // comment */"<<endl;
choice=getch();
if(choice=='c'||choice=='C'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl;
cout<<"The corrent answer is c"<<endl<<endl;
}
break;
case 3:
cout<<i+1<<") Who created C++?"<<endl;
cout<<"a) Bjarne Stroustrup"<<endl;
cout<<"b) Dennis Ritchie"<<endl;
cout<<"c) Ken Thompson"<<endl;
cout<<"d) Brian Kernighan"<<endl;
choice=getch();
if(choice=='A'||choice=='a'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl;
cout<<"The corrent answer is a"<<endl<<endl;
}
break;
case 4:
cout<<i+1<<") A language which has the capability to generate new data types are called"<<endl;
cout<<"a) Extensible"<<endl;
cout<<"b) Overloaded"<<endl;
cout<<"c) Encapsulated"<<endl;
cout<<"d) Reprehensible"<<endl;
choice=getch();
if(choice=='A'||choice=='a'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl;
cout<<"The corrent answer is a"<<endl<<endl;
}
break;
case 5:
cout<<i+1<<") Which of the following is called insertion/put to operator?"<<endl;
cout<<"a) <"<<endl;
cout<<"b) >"<<endl;
cout<<"c) <<"<<endl;
cout<<"d) >>"<<endl;
choice=getch();
if(choice=='c'||choice=='C'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl<<endl;
cout<<"The corrent answer is c"<<endl;
}
break;
case 6:
cout<<i+1<<") Which of the following is called extraction/get from operator?"<<endl;
cout<<"a) <"<<endl;
cout<<"b) >"<<endl;
cout<<"c) <<"<<endl;
cout<<"d) >>"<<endl;
choice=getch();
if(choice=='d'||choice=='D'){
cout<<choice<<" is correct Answer"<<endl<<endl;
st.marks++;
}
else{
cout<<choice<<" is incorrect Answer"<<endl;
cout<<"The corrent answer is d"<<endl<<endl;
}
break;
}
i++;
}
}
void java(){
//just copy cppp function code, paste here
//repace cpp questions to java questions
}
void html(){
//just copy cppp function code, paste here
//repace cpp questions to html questions
}
void result(){
float percentage=0;
cout<<"Student Name: "<<st.nam<<endl;
cout<<"Roll no: "<<st.rollno<<endl;
cout<<"Marks: "<<st.marks<<" out of 6"<<endl;
percentage=100*st.marks/6;
cout<<"Percentage: "<<percentage<<"%"<<endl;
if(percentage>=50){
cout<<"Status: Pass"<<endl;
}
else {
cout<<"Status: Fail"<<endl;
}
}
main(){
char press,select;
do
{
cout<<"\n\n\t\t****************"<<endl;
cout<<"\t\t QUIZ SYSTEM"<<endl;
cout<<"\t\t****************"<<endl;
cout<<"\t\tEnter name: ";
gets(st.nam);
cout<<"\t\tEnter rollno: ";
gets(st.rollno);
system("CLS");
cout<<"\t\tMarks less than 50% will be fail"<<endl;
cout<<"\n\nSelect option which subject's quiz you want to perform"<<endl;
cout<<"1) C++"<<endl;
cout<<"2) Java"<<endl;
cout<<"3) Html"<<endl;
select=getch();
system("CLS");
switch(select){
case '1':
cout<<"\t\tC++ Quiz"<<endl;
cppp();
system("CLS");
cout<<"\t\tC++ Quiz Result"<<endl;
result();
break;
case '2':
cout<<"\t\tJava Quiz"<<endl;
java();
system("CLS");
cout<<"\t\tJava Quiz Result"<<endl;
result();
break;
case '3':
cout<<"\t\tHtml Quiz"<<endl;
html();
system("CLS");
cout<<"\t\tHtml Quiz Result"<<endl;
result();
break;
default:
cout<<"Invalid input"<<endl;
break;
}
cout<<"Press y if you want to continue or any key to terminate"<<endl;
press=getch();
system("CLS");
}while(press=='y'||press=='Y');
}