-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrivia.c
More file actions
73 lines (66 loc) · 1.51 KB
/
trivia.c
File metadata and controls
73 lines (66 loc) · 1.51 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
/*trivia game*/
#include <stdio.h>
int s(void);
int g(void);
void pause(int x);
int s(void)
{
int a=0;
system("clear");
printf("\nthis is sport question");
printf("\nwhat university did nfl star deon attand?");
printf("\n1\tuniversity of miami\n2\tcaloforni state university\n3\tindiana university\n4\tflorida state university");
printf("\n choose your option: ");
scanf("%d",&a);
return a;
}
int g(void){
int a=0;
system("clear");
printf("\nthis is geography section");
printf("\nwhat is the capital of india\n1\tkolkata\n2\tdelhi\n3\tmumbai\n4\tahamdabad");
printf("\nchoose from above");
scanf("%d",&a);
return a;
}
main(){
int m=0;
int a=0,b=0;
system("clear");
do{printf("\nplay a trivia game");
printf("\nchoose from the following");
printf("\n1\tsports");
printf("\n2\tgeography");
printf("\n3\tquit:\n");
scanf("%d",&m);
switch(m){
case 1: if(s()==4){
printf("\ncorrect");
a++;
}
else
printf("\nincorrect");
b++;
pause(2);
break;
case 2:
if(g()==2){
printf("\ncorrect");
a++;
}
else
printf("\nincorrect");
b++;
pause(3);
break;
}
}while(m!=3);
printf("\ncorrect answers were: %d \nincrrect answers were: %d",a,b);
}
void pause(int x){
int q=0,w=0;
q=time(NULL);
do{
w=time(NULL);
}while((w-q)<x);
}