-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz game using linked list.txt
297 lines (276 loc) · 8.7 KB
/
quiz game using linked list.txt
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
typedef struct Node
{
char name[10];
int final_score;
struct Node *next;
} node;
int quiz(int score)
{
int ans;
printf("\n\n\t\t\t\t Who is father of C Language?\n\n\n\t\t");
printf("\t\t 1.Bjarne Stroustrup 2.James A.Gosling\n\n\t\t\t\t 3.Dennis Ritchie 4.Dr.E.F.Codd\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==3)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\t C programs are converted into machine language with the help of ?\n\n\n\t\t");
printf("\t\t 1.An Editor\t\t 2.A compiler\n\n\t\t\t\t 3.An operating system 4.None of these.\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==2)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\t A Queue is a ?\n\n\n\t\t");
printf("\t\t 1.FIFO(First in First out)list\t 2.Ordered array \n\n\t\t\t\t 3.LIFO(Last is Ftrst Out)list\t 4.Linear tree\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==1)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\t A Stack is a ?\n\n\n\t\t");
printf("\t\t 1.FIFO(First in First out)list\t 2.Ordered array \n\n\t\t\t\t 3.LIFO(Last is Ftrst Out)list\t 4.Linear tree\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==3)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\t Process of inserting an element in stack is called ?\n\n\n\t\t");
printf("\t\t 1.Create\t 2.Push\n\n\t\t\t\t 3.Evaluation\t 4.pop\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==2)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\t Process of removing an element in stack is called ?\n\n\n\t\t");
printf("\t\t 1.Create\t 2.Push\n\n\t\t\t\t 3.Evaluation\t 4.pop\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==4)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\tIn doubly linked lists, traversal can be performed ?\n\n\n\t\t");
printf("\t\t 1.Only in forward direction\t 2.In both directions\n\n\t\t\t\t 3.Only in reverse direction\t 4.None\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==2)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\tWhat is the time Complexity of inserting a node in a doubly linked list ?\n\n\n\t\t");
printf("\t\t 1.O(nlogn)\t 2.O(n)\n\n\t\t\t\t 3.O(logn)\t 4.O(1)\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==2)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\tWhat is the time Complexity of searching for element in a circular linked list ?\n\n\n\t\t");
printf("\t\t 1.O(nlogn)\t 2.O(1)\n\n\t\t\t\t 3.O(logn)\t 4.O(n)\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==4)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
printf("\n\n\t\t\t\tWhich of the following computer language is used for artificial intelligence?\n\n\n\t\t");
printf("\t\t 1.FORTRAN\t 2.C\n\n\t\t\t\t 3.PROLOG\t 4.COBOL\n\n");
printf("\n\t\t\t\tANS:");
scanf("%d",&ans);
if(ans==3)
{
printf("\nCorrect Ans.Plz press ENTER for Answer next the Qustion! \n\n\n");
score=score+3;
}
else
{
printf("\nSORRY,Wrong Ans.Plz press ENTER for Answer the next Qustion! \n\n\n");
score=score-1;
}
system ("PAUSE");
system("cls");
return score;
}
void insert(node *point, char name[],int final_score)
{
while(point->next!=NULL)
{
point = point -> next;
}
point->next = (node *)malloc(sizeof(node));
point = point->next;
strcpy(point->name, name);
point->final_score = final_score;
point->next = NULL;
printf("\n\n\n\n\t\t\t\t\t*** Store information! ***\n\n");
system ("PAUSE");
system("cls");
}
void print(node *point)
{
if(point==NULL)
{
return;
}
printf("\n\n\t\tName: %s \t\t final_score: %d \n\n\n",point->name,point->final_score);
print(point->next);
}
void h_print(node *point)
{
int max_score=point->final_score;
if (point==NULL)
{
return;
}
while(point!=NULL)
{
if(max_score < point->final_score)
{
max_score=point->final_score;
}
point=point->next;
}
printf("\n\t\thigh_score: %d\n",max_score);
printf("\n\t\tThank U for attending at quiz. See you again later!\n\n\n");
}
int main()
{
node *start,*temp;
char choice,name[20];
int final_score,score=0,value;
start = (node *)malloc(sizeof(node));
temp = start;
temp -> next = NULL;
printf("\n\n\n\n\t\t\t\t\t WELCOME TO QUIZ GAME\n\t\t\t\t\t||||||||||||||||||||||\n\t\t\t\t\t----------------------\n\n\n");
printf("\t\t\t\t\tEnter S | s FOR START\n \t\t\t\t\tENTER I | i FOR INFORMATION\n \t\t\t\t\tENTER Q | q FOR QUIT\n");
printf("\n\n\t\t\t\t\t|||||||||||||||||||||||\n\t\t\t\t\t-----------------------\n");
printf("\n\n\t\t\t\t\tGive me your choice:");
scanf("%c",&choice);
system("cls");
if(choice=='S' ||choice=='s' )
{
while(1)
{
printf("\n\n\t\tpress 1 to get Insert\n");
printf("\t\tpress 2 to get Result\n");
printf("\n\n\t\twhat do you want:");
scanf("%d",&value);
system("cls");
switch(value)
{
case 1:
printf("\n\nEnter your name plz:");
scanf("%s",name);
printf("\n\nhlw %s ,Let's start ->->\n\n",name);
final_score=quiz(score);
insert(start,name,final_score);
break;
case 2:
printf("\n## RESULT: ## ");
print(start->next);
printf("\n");
h_print(start->next);
printf("\n");
break;
default:
printf("invild selection\n\n");
}
}
}
else if(choice=='I' ||choice=='i')
{
printf("\n\n\n\t\t WELCOME TO QUIZ GAME\n\t\t||||||||||||||||||||||\n\t\t----------------------\n\n\n");
printf("This is a very easy game.Here we will ask some questions.\nYou have to answer them.for each answer 3 point will added,\nAnd if you are wrong 1 will diducted.best of luck!\n");
getch();
}
else if(choice=='Q' ||choice=='q')
{
printf("\n\n\n\n\n\n\n\t\t\t\t||| GOOD BYE,,,,,SEE YOU AGAIN |||\n\n\n");
getch();
}
else
{
printf("invild selection\n\n");
}
}