Uploads Files ButtonDetails 25228
Uploads Files ButtonDetails 25228
CERTIFICATE
This is to certify that the project work entitled “Kaun Banega Crorepati
Simulation” using CPP is presented by B.SC (COMPUTER SCIENCE)
STUDENTS in partial fulfillment of the requirements for the degree of Bachelor
The results embodied in this report have not been to any other University
or Institution for the award of any degree.
I hereby declare that the project report entitled “Kaun Banega Crorepati
2 Research Methodology 2
4. Game Rules 4
9 Output 52-65
10 Conclusion 66
11 Bibliography 67
INTRODUCTION:
KAUN BANEGA CROREPATI PROGRAMME is well famous and
popular game among many players all over the world. This report
details the development of a Kaun Banega Crorepati Simulation
Game application that is written in CPP Programming. In addition, the
report details the implementation to solve any kind of Quiz Game.
Also, how to generate a Game with different level of difficulties and
make sure there will be only one solution. The aim of the report is also
to discuss and other logics in order to create and solve Quiz Game.
Furthermore, the user-friendly environment is considered in the report
as the rules of Kaun Banega Crorepati are connected to the interface.
This programme improves methods of solving Quiz .The report
concludes by evaluating the end application to analyze how good it
met its objectives and the performance of Kaun Banega Crorepati
Simulation Game. Finally, the report summaries the overall
achievements of the application development and indicates other
possible extensions.Kaun Banega Crorepati (KBC) simulation system
is based on the television show by the same name, hosted by Mr.
Amitabh Bachchan. The main objective of this application is to provide
its users with an opportunity to play the famous quizzing game at the
comfort of their homes on a computer system. The main purpose of
this game is to make people learn new things and improve their
general knowledge, just by playing a game. You keep yourself updated
by recent current affairs. There is a good scope for improving one’s
general knowledge. You can be one step ahead of others. You can be
more confident on any topic and gain more knowledge and also able
to convey the information to others as you already know about it. By
this projects students will Acquire knowledge for developing many
more projects like KBC.
1
Research Methodology:
In order to run the program users have to first give the proper
path of the graphics driver which is available under bgi. To
check the whether graphics driver is available or not, you have
to quit the turbo C++ shell and you will be taken to the
C:\TURBOC3\BIN. You will have to change the directory to
check whether bgi driver is available or not. So you can change
directory by CD... and press enter. The directory of bgi can be
different as per the compiler you are using. This is the path of
the graphics driver which we have to give in this program to
enjoy the game.
To start this game, you have to press any key, you will be given
a question with 4 options which has been displayed at the
bottom of the page. A table with the amount is displayed at the
right side of the page, 3 Life lines are displayed at the top right
corner. For every right option you will be promoted to the next
level and you will awarded with some money. In case the player
is stuck with a question he can use any of his life lines. If the
player chooses the wrong option the game ends.
2
PROJECT AIMS AND OBJECTIVES:
3
GAME RULES:
4
Hardware and Software Requirements:
5
HEADER FILES USED
Filename Description
FSTREAM.H Provides functions for file and We/o handling
6
Functions used in the program:
Functions Description
8
SOURCE CODE:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<fstream.h>
#include<string.h>
int flag;
int ansbox1=0,ansbox2=0;
int life1=0,life2=0,life3=0,f3=0;
char str[8]={'0'};
char total[10]={'0'};
ifstream fin;
char correctans[2];
void page2();
void page3();
void line();
void questions();
void incorrect1();
void incorrect2();
9
void incorrect3();
void incorrect4();
void phonefriend();
void fiftyfifty();
void audiencepoll();
void sorry();
void select();
void correct();
void startscreen();
void totalprizemoney();
void music();
void askname();
int offset=0,num;
int prev[15],count=0;
initmouse()
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);}
void showmouseptr()
i.x.ax=1;
int86(0x33,&i,&o);
10
void hidemouseptr()
i.x.ax=2;
int86(0x33,&i,&o);
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
void main()
errorcode = graphresult();
11
printf("Press any key to halt:");
getch();
if(initmouse()==0)
closegraph();
restorecrtmode();
exit(1);
startscreen();
p=500;
ansbox1=0,ansbox2=0;
count=0;
life1=0,life2=0,life3=0;
page2();
hidemouseptr();
page3();
closegraph();
restorecrtmode();
12
}
void page2()
cleardevice();
settextstyle(12,0,5);
setcolor(10);
setlinestyle(1,0,1);
setcolor(BLUE);
setlinestyle(0,0,3);
rectangle(500,5,625,350);
line(0,350,625,350);
setcolor(LIGHTBLUE);
int poly[]={40,390,60,365,560,365,580,390,560,415,60,415,40,390};
drawpoly(7,poly);
line(0,390,40,390);line(580,390,620,390);
int poly1[]={40,430,50,420,290,420,300,430,290,445,50,445,40,430};
drawpoly(7,poly1);
int poly2[]={300,430,310,420,575,420,585,430,575,445,310,445,300,430};
drawpoly(7,poly2);
int poly3[]={40,465,50,450,290,450,300,465,290,475,50,475,40,465};
drawpoly(7,poly3);
int poly4[]={300,465,310,450,575,450,585,465,575,475,310,475,300,465};
line(0, 430,40,430);line(0,465,40,465);
line(585,430,620,430);line(585,465,620,465);
13
drawpoly(7,poly4);
setfillstyle(1,RED);
settextstyle(2,0,0);
fillellipse(525,20,20,10);
fillellipse(565,20,20,10);
fillellipse(605,20,20,10);
setcolor(YELLOW);
outtextxy(510,15,"50:50");
outtextxy(550,15,"PHONE");
outtextxy(589,13,"PUBLIC");
outtextxy(593,18,"vote");
settextstyle(12,0,2);
setcolor(YELLOW);
outtextxy(520,50," 10000000");
setcolor(LIGHTBLUE);
outtextxy(520,70," 5000000");
outtextxy(520,90," 2500000");
outtextxy(520,110," 1250000");
outtextxy(520,130," 640000");
setcolor(YELLOW);
outtextxy(520,150," 320000");
setcolor(LIGHTBLUE);
outtextxy(520,170," 160000");
outtextxy(520,190," 80000");
14
outtextxy(520,210," 40000");
outtextxy(520,230," 20000");
setcolor(YELLOW);
outtextxy(520,250," 10000");
setcolor(LIGHTBLUE);
outtextxy(520,270," 5000");
outtextxy(520,290," 3000");
outtextxy(520,310," 2000");
outtextxy(520,330," 1000");
count=0;
askname();
questions();
getch();
void page3()
cleardevice();
settextstyle(12,0,1);
for(int i=490;i>=200;i--)
setcolor(10);
15
setcolor(10);
setcolor(WHITE);
getch();
exit(0);
char proc[]={"PROCESSING........"};
void line()
setlinestyle(0,0,1);
for(int x=0;x<=485;x++)
{ setcolor(LIGHTGRAY);
line(x+10,20,x+10,340);
setcolor(0);
rectangle(0,20,x,340);
line(x+10,20,x+10,340);
setlinestyle(0,0,3);
sleep(1);
void questions()
char question[200];
char ans1[150];
16
char ans2[150];
char ans3[150];
char ans4[150];
int temp=0;
char ch,ch1;
int num=0,ct=0,i=0,t=0;
int randnum[15];
char str[4],co[4],numc[2];
randomize();
fin.open("KBC.txt",ios::binary);
while(!fin.eof())
fin.get(ch);
if(ch=='\n')
t++;
fin.close();
t=t/6;
fin.open("KBC.txt",ios::binary);
settextstyle(COMPLEX_FONT,0,3);
setcolor(RED);
sleep(3);
17
setcolor(BLACK);
while(ct<15)
count=0;
num=random(t);
for(i=0;i<temp;i++)
if(randnum[i]==num)
num=random(t);
i=0;
randnum[temp]=num;
temp++;
fin.seekg(0,ios::beg);
while(!fin.eof())
fin.get(ch);
if(ch=='\n')
count++;
if(count==(6*num))
18
break;
} if(ct>0)
setcolor(RED);
outtextxy(150,310,"NEXT question!!!!");
sleep(3);
setcolor(BLACK);
outtextxy(150,310,"NEXT question!!!!");
fin.getline(question,200,'\n');
fin.getline(ans1,150,'\n');
fin.getline(ans2,150,'\n');
fin.getline(ans3,150,'\n');
fin.getline(ans4,150,'\n');
fin.getline(correctans,2,'\n');
if(strlen(question)>=40||strlen(ans1)>=25||strlen(ans2)>=25||strlen(
ans3)>= 25||strlen(ans4)>=25)
settextstyle(COMPLEX_FONT,0,1);
else
settextstyle(COMPLEX_FONT,0,2);
setcolor(RED);
setcolor(15);
outtextxy(60,375,question);
outtextxy(60,415,ans1);
19
outtextxy(320,415,ans2);
outtextxy(60,445,ans3);
outtextxy(320,445,ans4);
showmouseptr();
if(correctans[0]=='a')
incorrect1();
else if(correctans[0]=='b')
incorrect2();
else if(correctans[0]=='c')
incorrect3();
else if(correctans[0]=='d')
incorrect4();
ct++;
if(ct==15)
20
totalprizemoney();
fin.close();
} void incorrect1()
count++;
showmouseptr();
flag=0;
select();
while(flag==0)
getmousepos(&button,&x1,&y1);
if((x1>=0&&x1<=300)&&(y1>=420&&y1<=445))
correct();
else
if((x1>=300&&x1<=585&&y1>=420&&y1<=445)||(x1>=0&&x1<=300&&y1>=
450&&y1<=475)||(x1>=300&&x1<=585&&y1>=450&&y1<=475))
sorry();
} void incorrect2()
{ count++;
showmouseptr();
flag=0;
21
select();
while(flag==0)
getmousepos(&button,&x1,&y1);
if((x1>=300&&x1<=585)&&(y1>=420&&y1<=445))
correct();
else if
((x1>=0&&x1<=300&&y1>=420&&y1<=445)||(x1>=0&&x1<=300&&y1>=450
&&y1<=475)||(x1>=300&&x1<=585&&y1>=450&&y1<=475))
sorry();
void incorrect3()
{ count++;
showmouseptr();
flag=0;
select();
while(flag==0)
getmousepos(&button,&x1,&y1);
22
{
if((x1>=0&&x1<=300)&&(y1>=450&&y1<=475))
correct();
else
if((x1>=0&&x1<=300&&y1>=420&&y1<=445)||(x1>=300&&x1<=585&&y1>=
420&&y1<=445)||(x1>=300&&x1<=585&&y1>=450&&y1<=475))
sorry();
void incorrect4()
{ count++;
showmouseptr();
flag=0;
select();
while(flag==0)
getmousepos(&button,&x1,&y1);
if((x1>=300&&x1<=585)&&(y1>=450&&y1<=475))
correct();
else
if((x1>=0&&x1<=300)&&(y1>=420&&y1<=445)||(x1>=300&&x1<=585&&y1>
=420&&y1<=445)||(x1>=0&&x1<=300&&y1>=450&&y1<=475))
sorry();
23
}
char prevstr[10]={"1000"};
void correct()
hidemouseptr();
flag=1;
p=p*2;
if(p==4000)
p=3000;
if(p==6000)
p=5000;
if(p==1280000)
p=1250000;
ltoa(p,str,10);
sleep(2);
setcolor(BLUE);
setfillstyle(1,YELLOW);
line(0,250,40,250);line(460,250,500,250);
int pol[]={40,250,60,235,460,235,480,250,460,265,60,265,40,250};
fillpoly(7,pol);
setcolor(BLUE);
24
settextstyle(0,0,3);
outtextxy(200,240,str);
settextstyle(0,0,1);
setcolor(WHITE);
setcolor(BLACK);
setfillstyle(1,BLACK);
settextstyle(0,0,1);
if(ansbox2==1)
bar(503,345+ansbox1,622,360+ansbox1);
setcolor(WHITE);
outtextxy(520,350+ansbox1,"");
outtextxy(540,350+ansbox1,prevstr);
setcolor(RED);
ansbox2=1;
setfillstyle(1,RED);
setcolor(WHITE);
settextstyle(0,0,1);
ansbox1=ansbox1-20;
bar(503,345+ansbox1,622,360+ansbox1);
outtextxy(520,350+ansbox1,"");
outtextxy(540,350+ansbox1,str);
ltoa(p,prevstr,10);
25
if(p==10000||p==320000||p==10000000)
music();
sleep(1);
setcolor(BLACK);
setfillstyle(1,BLACK);
bar3d(0,230,495,270,0,1);
settextstyle(COMPLEX_FONT,0,2);
setcolor(RED);
sleep(1);
setcolor(LIGHTBLUE);
setfillstyle(1,BLACK);
int poly[]={40,390,60,365,560,365,580,390,560,415,60,415,40,390};
fillpoly(7,poly);
line(0,390,40,390);line(580,390,620,390);
int poly1[]={40,430,50,420,290,420,300,430,290,445,50,445,40,430};
fillpoly(7,poly1);
int poly2[]={300,430,310,420,575,420,585,430,575,445,310,445,300,430};
fillpoly(7,poly2);
int poly3[]={40,465,50,450,290,450,300,465,290,475,50,475,40,465};
fillpoly(7,poly3);
int poly4[]={300,465,310,450,575,450,585,465,575,475,310,475,300,465};
line(0, 430,40,430);line(0,465,40,465);
line(585,430,620,430);line(585,465,620,465);
fillpoly(7,poly4);
26
}
void sorry()
hidemouseptr();
sleep(1);
setcolor(BLUE);
settextstyle(0,0,3);
outtextxy(50,200,"SORRY ! INCORRECT");
sleep(2);
fin.close();
clearviewport();
setcolor(BLUE);
totalprizemoney();
void totalprizemoney()
hidemouseptr();
clearviewport();
setcolor(BLUE);
setfillstyle(1,YELLOW);
line(0,390,40,390);line(580,390,620,390);
int pol[]={40,390,60,365,560,365,580,390,560,415,60,415,40,390};
fillpoly(7,pol);
27
setcolor(RED);
settextstyle(0,0,2);
setcolor(BLUE);
outtextxy(360,380,str);
settextstyle(0,0,1);
setcolor(GREEN);
setfillstyle(1,YELLOW);
bar(80,445,150,460);
do
outtextxy(100,450,"REPLAY EXIT");
a=getch();
switch(a)
case 13 :
if((flg%2)==0)
x='R';
else
x='E';
break;
case 77:
28
case 7
5:
if((flg%2)==0)
setfillstyle(1,0);
bar(80,445,150,460);
setfillstyle(1,YELLOW);
bar(200,445,270,460);
else
setfillstyle(1,0);
bar(200,445,270,460);
setfillstyle(1,YELLOW);
bar(80,445,150,460);
break;
if(a==75||a==77)
flg++;
}while(a!=13);
if(x=='R')
clearviewport();
29
closegraph();
main();
else if(x=='E')
page3();
closegraph();
exit(0);
setfillstyle(1,LIGHTBLUE);
setcolor(LIGHTBLUE);
drawpoly(7,poly);
ellipse(605,20,0,360,20,10);
ellipse(525,20,0,360,20,10);
ellipse(565,20,0,360,20,10);
setfillstyle(1,YELLOW);
setcolor(YELLOW);
void select()
30
int polygon1[]={40,430,50,420,290,420,300,430,290,445,50,445,40,430};
int
polygon2[]={300,430,310,420,575,420,585,430,575,445,310,445,300,430};
int polygon3[]={40,465,50,450,290,450,300,465,290,475,50,475,40,465};
int
polygon4[]={300,465,310,450,575,450,585,465,575,475,310,475,300,465};
setcolor(RED);
setfillstyle(1,RED);
setlinestyle(1,0,15);
do
settextstyle(3,0,2);
setcolor(BLACK);
x:
getmousepos(&button,&x1,&y1);
if(x1>=0&&x1<=300&&y1>=420&&y1<=445)
pass(polygon2);
pass(polygon3);
pass(polygon4);
drawpoly(7,polygon1);
else if(x1>=300&&x1<=585&&y1>=420&&y1<=445)
pass(polygon1);
31
pass(polygon3);
pass(polygon4);
drawpoly(7,polygon2);
else if(x1>=0&&x1<=300&&y1>=450&&y1<=475)
pass(polygon1);
pass(polygon2);
pass(polygon4);
drawpoly(7,polygon3);
/*
putimage(50,425,arrow1,1);
putimage(330,425,arrow1,1);
putimage(50,455,arrow,1);
putimage(330,455,arrow1,1);
*/
else if(x1>=300&&x1<=585&&y1>=450&&y1<=475)
pass(polygon1);
pass(polygon3);
pass(polygon2);
drawpoly(7,polygon4);
32
//select lifeline.................................
//50:50
else if(x1>=505&&x1<=545&&y1>=10&&y1<=30)
if(life1==1&&(button &1)==1)
settextstyle(3,0,2);
setcolor(YELLOW);
goto x;
setcolor(YELLOW);
ellipse(525,20,0,360,20,10);
setcolor(LIGHTBLUE);
ellipse(605,20,0,360,20,10);
ellipse(565,20,0,360,20,10);
fiftyfifty();
goto x;
//Phone a friend
else if(x1>=545&&x1<=585&&y1>=10&&y1<=30)
if(life2==1&&(button &1)==1)
33
{
settextstyle(3,0,2);
setcolor(YELLOW);
goto x;
setcolor(YELLOW);
ellipse(565,20,0,360,20,10);
setcolor(LIGHTBLUE);
ellipse(605,20,0,360,20,10);
ellipse(525,20,0,360,20,10);
phonefriend();
goto x;
//audience poll
else if(x1>=585&&x1<=625&&y1>=10&&y1<=30)
if(life3==1&&(button &1)==1)
settextstyle(3,0,2);
setcolor(YELLOW);
goto x;
34
setcolor(YELLOW);
ellipse(605,20,0,360,20,10);
setcolor(LIGHTBLUE);
ellipse(565,20,0,360,20,10);
ellipse(525,20,0,360,20,10);
audiencepoll();
goto x;
void startscreen()
setlinestyle(0,0,3);
setcolor(BLUE);
setfillstyle(1,BLUE);
circle(300,225,225);
floodfill(300,200,BLUE);
setcolor(LIGHTBLUE);
setfillstyle(1,LIGHTBLUE);
circle(300,225,185);
floodfill(300,200,LIGHTBLUE);
35
setcolor(0);
setfillstyle(SLASH_FILL,0);
setlinestyle(1,0,0);
for(int p=0;p<=185;p++)
circle(300,225,p);
delay(10);
setlinestyle(1,0,3);
setcolor(BLUE);
setfillstyle(7,BLUE);
fillellipse(300,225,30,185);
fillellipse(300,225,185,30);
setcolor(BLUE);
setcolor(15);
setfillstyle(1,15);
setcolor(15);
settextstyle(8,0,5);
settextstyle(0,0,3);
outtextxy(100,125,"K");
outtextxy(125,85,"A");
outtextxy(155,55,"U");
outtextxy(195,25,"N");
36
outtextxy(300,10,"B");
outtextxy(350,20,"A");
outtextxy(395,35,"N");
outtextxy(435,65,"E");
outtextxy(465,105,"G");
outtextxy(485,140,"A");
setcolor(YELLOW);
outtextxy(495,180,"-");
outtextxy(85,180,"-");
outtextxy(495,250,"");
outtextxy(85,250,"");
setcolor(15);
outtextxy(100,305,"K");
outtextxy(125,345,"A");
outtextxy(155,375,"U");
outtextxy(195,405,"N");
outtextxy(300,420,"B");
outtextxy(350,415,"A");
outtextxy(395,395,"N");
outtextxy(435,365,"E");
outtextxy(465,335,"G");
outtextxy(485,290,"A");
setlinestyle(1,0,3);
37
setcolor(5);
setfillstyle(0,5);
circle(300,225,185);
settextstyle(12,0,5);
setcolor(10);
setlinestyle(1,0,1);
setcolor(15);
settextstyle(8,0,5);
outtextxy(265,195," E ");
sound(1000);
delay(600);
outtextxy(215,195," R ");
outtextxy(315,195," P ");
sound(1100);
delay(600);
sound(1200);
delay(500);
outtextxy(170,195," O ");
outtextxy(365,195," A ");
sound(1000);
delay(500);
sound(1100);
38
delay(550);
outtextxy(115,195," R ");
outtextxy(400,195," T ");
sound(1200);
delay(450);
sound(1350);
delay(450);
outtextxy(85,195,"C ");
outtextxy(500,195,"I");
sound(1500);
delay(1000);
nosound();
settextstyle(0,0,1);
getch();
void music()
sound(1000);
delay(600);
sound(1100);
delay(600);
39
sound(1200);
delay(500);
sound(1000);
delay(500);
sound(1100);
delay(550);
sound(1200);
delay(450);
sound(1350);
delay(450);
sound(1500);
delay(1000);
nosound();
void askname()
settextstyle(0,0,1);
setcolor(7);
char name[40];
gotoxy(30,8);
cin.getline(name,40);
40
outtextxy(0,150,"please enter your city : ");
char city[40];
gotoxy(30,10);
cin.getline(city,40);
sleep(1);
line();
sleep(1);
setcolor(7);
setcolor(RED);
outtextxy(150,90,name);
outtextxy(320,110,city);
setcolor(LIGHTGREEN);
sleep(2);
setcolor(LIGHTGRAY);
sleep(2);
setcolor(LIGHTGREEN);
sleep(2);
41
setcolor(LIGHTGRAY);
sleep(2);
setcolor(WHITE);
sleep(2);
settextstyle(0,0,1);
getch();
line();
settextstyle(BOLD_FONT,0,1);
void phonefriend()
settextstyle(3,0,2);
setcolor(BLACK);
if(((button &1)==1)&&life2==0)
42
{
hidemouseptr();
setcolor(LIGHTBLUE);
settextstyle(0,HORIZ_DIR,2);
sleep(1);
sleep(1);
line();
setcolor(LIGHTGRAY);
setfillstyle(2,RED);
circle(300,200,100);
char arc[10];
settextstyle(0,HORIZ_DIR,5);
int x=0;
setfillstyle(1,DARKGRAY);
for(int i=0;i<=30;i++)
setcolor(BLACK);
pieslice(300,200,0,i*12,97);
itoa(i,arc,10);
setcolor(BLUE);
if(i>=10)
43
x=25;
outtextxy(280-x,180,arc);
sleep(1);
setcolor(BLACK);
outtextxy(280-x,180,arc);
life2=1;
setcolor(YELLOW);
settextstyle(3,HORIZ_DIR,3);
sleep(3);
line();
showmouseptr();
void fiftyfifty()
settextstyle(3,0,2);
setcolor(BLACK);
randomize();
int r1=0,r2=0;
44
if(((button &1)==1)&&life1==0)
setcolor(LIGHTBLUE);
settextstyle(0,HORIZ_DIR,2);
sleep(1);
outtextxy(280,290,"BE ELIMINATED");
sleep(1);
line();
if(correctans[0]=='a')
while(r1==0||r2==0||r1==r2)
r1=random(4);
r2=random(4);
if(correctans[0]=='b')
while(r1==1||r2==1||r1==r2)
r1=random(4);
r2=random(4);
45
}
if(correctans[0]=='c')
while(r1==2||r2==2||r1==r2)
r1=random(4);
r2=random(4);
if(correctans[0]=='d')
while(r1==3||r2==3||r1==r2)
r1=random(4);
r2=random(4);
setcolor(BLACK);
setfillstyle(1,BLACK);
int poly1[]={40,430,50,420,290,420,300,430,290,445,50,445,40,430};
int poly2[]={300,430,310,420,575,420,585,430,575,445,310,445,300,430};
int poly3[]={40,465,50,450,290,450,300,465,290,475,50,475,40,465};
int poly4[]={300,465,310,450,575,450,585,465,575,475,310,475,300,465};
46
if(r1==0)
fillpoly(7,poly1);
else if(r1==1)
fillpoly(7,poly2);
else if(r1==2)
fillpoly(7,poly3);
else if(r1==3)
fillpoly(7,poly4);
if(r2==0)
fillpoly(7,poly1);
else if(r2==1)
fillpoly(7,poly2);
else if(r2==2)
fillpoly(7,poly3);
else if(r2==3)
fillpoly(7,poly4);
life1=1;
void audiencepoll()
settextstyle(3,0,2);
setcolor(BLACK);
47
randomize();
int r1=0,r2=0,r3=0,r4=0;
if(((button &1)==1)&&life3==0)
hidemouseptr();
setcolor(LIGHTBLUE);
settextstyle(0,HORIZ_DIR,2);
sleep(2);
line();
if(correctans[0]=='a')
while(r1<r2||r1<r3||r1<r4||r1+r2+r3+r4!=100)
r1=random(100);
r2=random(100);
r3=random(100);
r4=random(100);
else if(correctans[0]=='b')
while(r2<r1||r2<r3||r2<r4||r1+r2+r3+r4!=100)
48
r1=random(100);
r2=random(100);
r3=random(100);
r4=random(100);
else if(correctans[0]=='c')
while(r3<r1||r3<r2||r3<r4||r1+r2+r3+r4!=100)
r1=random(100);
r2=random(100);
r3=random(100);
r4=random(100);
else if(correctans[0]=='d')
while(r4<r1||r4<r2||r4<r3||r1+r2+r3+r4!=100)
r1=random(100);
r2=random(100);
r3=random(100);
r4=random(100);
49
}
char r11[20];
itoa(r1,r11,10);
itoa(r2,r22,10);
itoa(r3,r33,10);
itoa(r4,r44,10);
setcolor(YELLOW);
bar(240,150-r1,260,150);
bar(265,150-r2,280,150);
bar(285,150-r3,300,150);
bar(305,150-r4,320,150);
settextstyle(0,0,1);
setcolor(GREEN);
outtextxy(240,152,"A B C D");
outtextxy(240,140-r1,r11);
outtextxy(265,140-r2,r22);
outtextxy(285,140-r3,r33);
outtextxy(305,140-r4,r44);
setcolor(RED);
rectangle(230,30,330,175);
life3=1;
f3=1;
setcolor(YELLOW);
50
settextstyle(1,0,2);
showmouseptr();
getch();
line();
51
OUTPUT SCREENS:
52
65
Conclusion and Suggestions:
66
REFERENCES:
1. B. Lippman, C++ Primer
2. Bruce Eckel, Thinking in C++
3. K.R.Venugopal, Mastering C++
4. Herbert Schildt, C++: The Complete Reference
5. BjarneStroustrup, The C++ Programming Language ,Object Oriented
Programming with c++.
67