-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRANNKBC.c
163 lines (143 loc) · 3.59 KB
/
RANNKBC.c
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
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void answer();
void money();
FILE *fptr;
char line[200];
char ch;
int flag=1,flag1=1;
int j;
char ans;
int count1=1;
int count2=1;
int mon=1000;
int mon1=0;
int flag2=1;
int main()
{
/*INTRO*/
printf("------------------------WELCOME TO KBC------------------------\n");
printf("THE RULES ARE \n 1. ONLY ONE PERSON CAN PLAY AT A TIME \n 2. MONEY IS ADDED TO EXISTING AMOUNT AFTER EVERY QUESTION \n 3. THERE ARE 2 LIFELINES YOU CAN USE\n");
char opt;
int i=4,count=1;
int linenumber;
fptr=fopen("kbc.txt","r");
/*QUESTIONS*/
do
{
linenumber=i;
printf("\n");
printf("\n");
printf("\n_____YOU WILL RECEIVE %d RUPEES FOR THIS QUESTION_____\n",mon-mon1);
while(fgets(line, sizeof line, fptr)!='\0')
{
if(count<linenumber)
{
printf(" %s",line);
}
else if(count==linenumber)
{
break;
}
count++;
}
i=i+4;
if(count2==1)
/*LIFELINE*/
{
printf("\n DO YOU WANT ANY LIFELINE? \n IF YESS ENTER Y\n IF NO ENTER N \n ");
scanf(" %c",&opt);
if(opt=='Y' || opt=='y')
{
char ans1;
ch=line[0];
printf("\n ENTER YOUR FIRST ANSWER: \n");
scanf(" %c",&ans);
if(tolower(ans)!=tolower(ch))
{
printf("\n ENTER YOUR SECOND ANSWER \n");
scanf(" %c",&ans1);
if(tolower(ans1)==tolower(ch))
/*2ND ATTEMPT*/
{
// (only applicable to windows ) Beep(659,1200);
// (only applicable to windows ) Beep(698,350);
printf("__________________________________________");
printf("\n|------ CONGRATS! CORRECT ANSWER---------|");
money();
flag=1;
}
else
{
printf("WRONG ANSWER\n");
flag=0;
}
}
/*1ST ATTEMPT*/
else
{
// (only applicable to windows ) Beep(659,1200);
// (only applicable to windows ) Beep(698,350);
printf("__________________________________________");
printf("\n|------ CONGRATS! CORRECT ANSWER---------|");
money();
flag=1;
}
count2++;
}
else if(opt=='N' || opt=='n')
{
answer();
}
}
else
{
answer();
}
}while(flag==1);
return 0;
}
/*ANSWERS*/
void answer()
{
int j=1;
char ans;
int count1=1;
printf(" enter the answer: ");
scanf(" %c",&ans);
if(count1==j)
{
ch=line[0];
if(tolower(ans)==tolower(ch))
{
// (only applicable to windows ) Beep(659,1200);
// (only applicable to windows ) Beep(698,350);
printf("__________________________________________");
printf("\n|------ CONGRATS! CORRECT ANSWER---------|");
money();
flag=1;
}
else
{
printf("\nWRONG ANSWER");
flag=0;
printf("\nYOU WON TOTAL %d RUPEES",mon1);
}
count1++;
}
j=j+1;
count1=count1-1;
}
/*MONEY*/
void money()
{
if(mon==1024000)
{
flag2=0;
}
mon1=mon;
printf("\n|---- YOU WON TOTAL %8d RUPEES!!!---|\n",mon);
printf("|________________________________________|");
mon=mon*2;
}