You are on page 1of 14

/**************************A PROGRAM TO PLAY QUIZ

**********************/

/*******************************HEADER FILES****************************/

#include<fstream.h>
#include<process.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<string.h>

/*******************************CLASS***********************************/

class quiz
{
int score;
char name[21];
public:
void scorecard();

/******************************* SCORE *********************************/

Void highscore()
{
d.score=sc;
cout<<"\n\n\nEnter your name :- ";
gets(d.name);
ofstream fin("Record",ios::ate);
if(!fin)
{
cout<<"Insufficient Memory";
exit(0);
}
fin.write((char*) &d,sizeof(d));
fin.close();
}

} d;

/************************* GLOBAL VARIABLES ****************************/

int sc=0,j=0; //sc used for keeping scores, j used for password
char a,crack[8]; //am used in mains , crack for entry made
char Password[]="word";
char ch='y';

/***************************** SCORECARD********************************/

void quiz::scorecard()
{
clrscr();
quiz d1;
char g;
char cname[21];
fstream fout1("Record",ios::out||ios::binary);
fout1.seekg(0);
fout1.read((char*)&d1,sizeof (d1));
fout1.close();

1

name)) { cout<<s<<") "<<d.name). exit(0). cout<<"\n\n\t\t\t\tINSUFFICIENT MEMORY ". cout<<"\tENTER(1/2/3) ".sizeof(d))) { ab=strlen(d. } } cout<<"\n\n\n". } else { for(. cout<<"\n\n NAME\t\t\t\bSCORE\n\n".score<<endl<<endl.d.SCORE\n\n".ab<20. cout<<"============\n\n". switch(g) { case '1': { clrscr(). } 2 . gets(cname).score<<" POINTS\n". cout<<"\n\n NAME . cout<<s<<") "<<d.score>=d1. fout. cout<<"\n ENTER NAME ". break. if(d. } s++. } cout<<"\n\n OPTIONS :.score=d.read((char*)&d.score) { d1.d. cout<<d. if(strlen(d.sizeof(d))) { if(!strcmpi(cname.name)==20) { cout<<d.ios::out||ios::binary).fstream fout("Record".name). strcpy(d1."<<endl.score<<endl<<endl.name<<" WITH "<<d1. g=getch(). cout<<"\t 3) BY SCORE"<<endl<<endl.score<<endl<<endl. cout<<"\t 1) COMPLETE VIEW"<<endl<<endl. delay(2000).name<<" . cout<<"\t 2) BY NAME"<<endl<<endl. while(fout. cout<<"TOP SCORER : "<<d1. } case '2': { clrscr().name.score. while(fout. s++.name."<<d.ab++)cout<<" ". if(!fout) { cout<<"\n\n\t\t\t\t NO RECORD FOUND ".seekg(ios::beg). cout<<"\n\n\t\t\t\t OR ".read((char*)&d.

} break. gotoxy(1. } } if(s==1) { cout<<"\n\nNO RECORD AVAILABLE". } /*******************************DECO************************************/ void deco() { clrscr(). cout<<" | | |||||| | |||||| ||||| || || ||||||\n". cout<<"\n\n\n\n\n". cout<<"\n ENTER SCORE ". } break.name.name.score<<endl<<endl. } cout<<d. } case '3': { clrscr(). cout<<"\n\n\n\n\n\n". cout<<" | | | | | | | || || | \n". cout<<" | | | | | | | | | | | | \n".sizeof(d))) { ab=strlen(d.name). while(fout. } } fout. delay(1000). cout<<"\n\n NAME\t\t\tSCORE\n\n". } else { for(. cout<<"\n\n\t\t\t\t Wrong entry made"<<endl.score) { cout<<s<<") "<<d. cin>>c. s++. if(c==d. } default: { clrscr().ab++) cout<<" ".read((char*)&d.ab<=20. 3 . break.close(). if(ab==20) { cout<<d.} if(s==1) { cout<<"\n\nNO RECORD AVAILABLE".5).

am<=3. getch(). cout<<am. clrscr().50). cout<<" | | | ||||| | | | | | | ||||| \n". cout<<"\n\n\n\n". cout<<"\t\t============================================= =". gotoxy(31. for(int am=0. } if(j==4) { clrscr().cout<<" | | | | | | | | | | | \n". } else cout<<"*". } for(am=0. cout<<" || || | | | | | | | | \n". cout<<" | || | | | | | | | | | \n".am++) { if(Password[am]==crack[am]) j++. gotoxy(53. if(crack[am]==' ') { am--. cout<<" | | | | | | | | | | | | \n". } } } /*******************************BEGIN***********************************/ void begin() { cout<<"\n\n\n\n\n\t\t\t\t\b\b\b\b". cout<<"\t\t\t WELCOME TO THE QUIZ ". cout<<"\n\n\t\t\t\t ". 4 . cout<<"\n\n\n\n\n\n". gotoxy(40. cout<<"**----ENTER PASSWORD----** ".am++) { crack[am]=getch(). cout<<"!! Here we go !!".22). delay(1000). cout<<"\n\n\n\n\n\n".am>0.am<=3.am--) { clrscr(). cout<<" || || |||||| |||||| |||||| ||||| | | ||||||\n"<<endl. delay(700). for(int am=10.25). if(am==1) { clrscr(). cout<<"Press any key to continue :-".

cout<<"\n\t\t\t\t\b\bOPERATION ABORTED". cout<<"YOU ARE WRONG ". delay(1000). a=getch(). cout<<"YOUR SCORE IS ". cout<<"\n\n\n\n\n". cout<<"\n\n\n\t\t\tYour score is "<<sc<<" out of 45". cout<<sc. cout<<"\n\n\n Do you want to continue (Y/N)". } cout<<"\n\n\t\t". delay(500). cout<<"\n\n\n\t\tEnter your choice ". cout<<"\n\na) Ghatotkach\n\nb) Karna\n\nc) Madhavan\n\nd) Yoyutsu". exit(0). } } /******************************* RESULT ********************************/ void result() { clrscr(). delay(1000). sc=sc+3. else if(sc>=30) cout<<"\n\n\t\t\tNice performance". if(sc==45) cout<<"\n\n\t\t\tExcellent performance". } /*****************************QUESTIONS*********************************/ void question1() { clrscr(). ch=getch(). else if(sc>=20) cout<<"\n\n\t\t\tGood performance". cout<<a. else cout<<"\n\n\t\t\t Needs Improvement". 5 . } else { clrscr().cout<<"\t\t============================================= =". cout<<"YOU ARE CORRECT". if (a=='d'||a=='D') { cout<<"\n\n\t\t". } else { cout<<"\n\n\t\t". cout<<"QUES 1:-Among the Kaurawas who have helped the Pandavas ?".

} cout<<"\n\n\t\t". } else { cout<<"\n\n\t\t". cout<<"\n\n\n Do you want to continue (Y/N)". cout<<"QUES 4:-Name the award which cannot be given to a sports personality. cout<<"YOUR SCORE IS ". cout<<"YOU ARE WRONG ". cout<<"YOU ARE CORRECT". a=getch(). cout<<"YOUR SCORE IS ". } cout<<"\n\n\t\t". if (a=='c'||a=='C') { cout<<"\n\n\t\t". 6 . cout<<sc. cout<<"\n\na) Gallantry awards\n\nb) Arjun awards\n\nc)Dronacharya awards\n\nd) Khel Ratna". cout<<"QUES 3:-Through which state capital the tropic of cancer does not passes. if(ch=='y') { clrscr(). } else { cout<<"\n\n\t\t". cout<<"\n\n\n\t\tEnter your choice ". ch=getch(). cout<<a.". cout<<"YOU ARE CORRECT".cout<<a. cout<<sc. ch=getch(). sc=sc+3. cout<<"\n\na) Bhopal\n\nb) Raipur\n\nc) Aizwal\n\nd) Gandhinagar". a=getch(). cout<<"\n\n\n\n\n". if(ch=='y') { clrscr().". cout<<"YOU ARE WRONG ". if (a=='b'||a=='B') { cout<<"\n\n\t\t". sc=sc+3. cout<<"\n\n\n\n\n". cout<<"\n\n\n\t\tEnter your choice ". cout<<"QUES 2:-Which state doesnot have it's HIGH COURT in it's capital ?". cout<<"\n\n\n\t\tEnter your choice ". cout<<"\n\n\n Do you want to continue (Y/N)". cout<<"\n\n\n\n\n". cout<<"\n\na) Jharkhand\n\nb) West Bengal\n\nc) Madhya Pradesh\n\nd) Andhra Pradesh".if(ch=='y') { clrscr().

cout<<"YOU ARE WRONG ". cout<<"YOUR SCORE IS ". cout<<"YOU ARE CORRECT". cout<<sc. cout<<"YOU ARE CORRECT". if(ch=='y') { clrscr(). } else { cout<<"\n\n\t\t". } else { cout<<"\n\n\t\t". cout<<"\n\n\n\n\n". sc=sc+3. ch=getch().cout<<a. cout<<"QUES 6:-Which mela takes place after every 6 years ?". if(ch=='y') { clrscr(). cout<<"YOU ARE WRONG ". ch=getch(). if (a=='c'||a=='C') { cout<<"\n\n\t\t". sc=sc+3.cout<<a. } cout<<"\n\n\t\t". cout<<"\n\n\n\t\tEnter your choice ". cout<<" YOU ARE CORRECT". cout<<"YOU ARE WRONG ". cout<<"\n\na) Bharat\n\nb) India\n\nc) Republic of India\n\nd) Republic of Bharat". cout<<"\n\na) Kumbh mela\n\nb) Ardh\n\nc) Purna\n\nd) Purna Kumbh melas". a=getch().a=getch(). if (a=='b'||a=='B') { cout<<"\n\n\t\t". cout<<sc. } cout<<"\n\n\t\t". cout<<"\n\n\t\tEnter your choice ". 7 . cout<<"YOUR SCORE IS ". cout<<"QUES 5:-What is the official name of India in English ?". a=getch().cout<<a. cout<<"\n\n\n Do you want to continue (Y/N)". sc=sc+3. if (a=='a'||a=='A') { cout<<"\n\n\t\t". } else { cout<<"\n\n\t\t". cout<<"\n\n\n Do you want to continue (Y/N)". cout<<"\n\n\n\n\n".

cout<<"QUES 7:-Purna Kumbh mela takes place after how many years ?". } else { cout<<"\n\n\t\t". a=getch(). cout<<"\n\n\n Do you want to continue (Y/N)". } cout<<"\n\n\t\t". sc=sc+3. cout<<"YOUR SCORE IS ". cout<<"\n\n\t\tEnter your choice ". cout<<sc. cout<<"\n\na) Calcutta session of 1911\n\nb) Madras session of 1910\n\nc) Nagpur session of 1913\n\nd) Delhi session of 1913". if (a=='d'||a=='D') { cout<<"\n\n\t\t". } cout<<"\n\n\t\t". cout<<"YOU ARE CORRECT".cout<<a. cout<<"QUES 8:-In which session did the congress sung the NATIONAL ANTHEM for the first time ?". cout<<sc. cout<<"YOU ARE WRONG ". if(ch=='y') 8 . sc=sc+3. if(ch=='y') { clrscr(). cout<<sc. if(ch=='y') { clrscr(). cout<<"\n\n\n\n\n". cout<<"YOUR SCORE IS ". ch=getch(). ch=getch(). cout<<"\n\n\n Do you want to continue (Y/N)". ch=getch().cout<<a.} cout<<"\n\n\t\t". if (a=='a'||a=='A') { cout<<"\n\n\t\t". cout<<"YOU ARE WRONG ". a=getch(). cout<<"\n\n\n Do you want to continue (Y/N)". cout<<"\n\n\n\n\n". cout<<"YOUR SCORE IS ". cout<<"YOU ARE CORRECT". cout<<"\n\n\t\tEnter your choice ". } else { cout<<"\n\n\t\t". cout<<"\n\na) 120\n\nb) 140\n\nc) 132\n\nd) 144".

} else { cout<<"\n\n\t\t". cout<<sc. if (a=='d'||a=='D') { cout<<"\n\n\t\t". } cout<<"\n\n\t\t". ch=getch(). cout<<"\n\n\t\tEnter your choice ". if (a=='c'||a=='C') { 9 . cout<<"YOUR SCORE IS ". } cout<<"\n\n\t\t". a=getch(). if (a=='a'||a=='A') { cout<<"\n\n\t\t". cout<<"\n\n\n\n\n". cout<<"YOU ARE CORRECT". cout<<"\n\n\t\tEnter your choice ". cout<<"QUES 11:-In which state India's first GRANITE TEMPLE is located ?". a=getch(). cout<<sc. cout<<"YOU ARE CORRECT". sc=sc+3.cout<<a. cout<<"\n\n\n Do you want to continue (Y/N)".{ clrscr(). cout<<"\n\n\t\tEnter your choice ". ch=getch(). if(ch=='y') { clrscr(). cout<<"\n\n\n\n\n".cout<<a. cout<<"\n\n\n\n\n". cout<<"\n\na) Parikshit\n\nb) Janamejaya\n\nc) Abhimanyu\n\nd) Virata". cout<<"\n\n\n Do you want to continue (Y/N)". cout<<"YOU ARE WRONG ". cout<<"\n\na) Yuvraj Singh\n\nb) Sachin Tendulkar\n\nc) Mahendra Singh Dhoni\n\nd) Suresh Raina". sc=sc+3.cout<<a. cout<<"YOU ARE WRONG ". } else { cout<<"\n\n\t\t". cout<<"QUES 10:-Who has scored centuries in all formats of CRICKET ?". if(ch=='y') { clrscr(). cout<<"QUES 9:-Who was the grandson of Arjun in the MAHABHARATA ?". cout<<"YOUR SCORE IS ". a=getch(). cout<<"\n\na) Karnataka\n\nb) Madhya pradesh\n\nc) Tamil nadu\n\nd) Kerala".

cout<<"YOU ARE CORRECT". ch=getch(). cout<<"YOU ARE WRONG ". cout<<"\n\n\t\tEnter your choice ". 10 . cout<<sc. cout<<"YOU ARE CORRECT". cout<<"\n\na) Coronation bridge( West Bengal ) \n\nb) Ponte de inhares( Goa )\n\nc) Prakasam Barrage( Andhra Pradesh)\n\nd) Baily Bridge( Jammu & Kashmir )".cout<<a. if (a=='a'||a=='A') { cout<<"\n\n\t\t". sc=sc+3. cout<<"YOU ARE WRONG ". } cout<<"\n\n\t\t". cout<<"YOUR SCORE IS ". cout<<"QUES 12:-Baily Bridge is situated in which state ?". cout<<"YOU ARE WRONG ". cout<<sc. cout<<"\n\na) Jammu & Kashmir\n\nb) Goa\n\nc) Andhra Pradesh\n\nd) Haryana". } else { cout<<"\n\n\t\t".cout<<a. } else { cout<<"\n\n\t\t". a=getch(). sc=sc+3. if(ch=='y') { clrscr(). sc=sc+3. cout<<"QUES 13:-Which one of the following bridge is situated at highest altitude ?". a=getch(). cout<<"\n\n\t\tEnter your choice ". if (a=='d'||a=='D') { cout<<"\n\n\t\t". cout<<"\n\n\n\n\n". cout<<"YOUR SCORE IS ". cout<<"\n\n\n Do you want to continue (Y/N)". if(ch=='y') { clrscr(). cout<<"YOU ARE CORRECT". } else { cout<<"\n\n\t\t". cout<<"\n\n\n\n\n".cout<<"\n\n\t\t". } cout<<"\n\n\t\t". cout<<"\n\n\n Do you want to continue (Y/N)". ch=getch().

} cout<<"\n\n\t\t". cout<<"QUES 15:-Which is the HIGHEST DAM in INDIA ?". cout<<"YOU ARE CORRECT".V.cout<<a.Expressway".cout<<a. cout<<"\n\na) Bhakra Nangal Dam\n\nb) Hirakud Dam\n\nc) Nagarjunasagar Dam\n\nd) Tehri dam". delay(1500). cout<<"QUES 14:-Which is the LONGEST SEA BRIDGE in INDIA ?". a=getch(). cout<<"\n\na) Hosur Road Elevated Expressway \n\nb) Annai Indira Gandhi\n\nc) Bandra Worli Sea Link\n\nd) P. cout<<"\n\n\n\n\n". if(ch=='y') { clrscr().} cout<<"\n\n\t\t". ch=getch(). cout<<"\n\n\n\t\tEnter your choice ". if(ch=='y') { clrscr(). cout<<"YOUR SCORE IS ". } cout<<"\n\n\t\t". cout<<sc. cout<<sc. a=getch(). cout<<"\n\n\n Do you want to continue (Y/N)". } else { cout<<"\n\n\t\t". cout<<"YOU ARE WRONG ". cout<<sc. } else { cout<<"\n\n\t\t". sc=sc+3. cout<<"YOUR SCORE IS ". cout<<"YOU ARE CORRECT". cout<<"\n\n\n\t\tEnter your choice ". cout<<"YOUR SCORE IS ". }}}}}}}}}}}}}}} 11 . cout<<"\n\n\n Do you want to continue (Y/N)". ch=getch(). cout<<"YOU ARE WRONG ". sc=sc+3. cout<<"\n\n\n\n\n". if (a=='d'||a=='D') { cout<<"\n\n\t\t". if (a=='c'||a=='C') { cout<<"\n\n\t\t".

cout<<"\n\n\n ABOUT:-". cout<<"\n\n\n\n\n\n". cout<<"\n--------------". cout<<"3:. d. culture. cout<<"\n\n MAIN OPTIONS\n". char am. while(ch=='y') { clrscr(). cout<<"\n\n India's history. cout<<"\n\n the nation . cout<<"\n--------". Every question will have". You will be". clrscr(). 12 . myths. sc=0. char ch='y'. result(). } /*******************************MAIN************************************/ void main() { void end(). cout<<"===============\n\n\t". am=getch(). sports & latest happenings in ". cout<<"\n\n\n\t This play has only 15 questions . begin(). question1(). //textbackground(BLUE).PLAYGAME"<<endl<<endl<<"\t". deco(). cout<<"2:. delay(3000). textcolor(GREEN).highscore().EXIT"<<endl<<endl<<"\t". cout<<"\n\n awarded points for every correct answer.SCORECARD"<<endl<<endl<<"\t". cout<<"\n\n four options out of which only one is correct . cout<<"1:. switch(am) { case '1': { playgame(). ". ". cout<<"\n\n\n\nINSTRUCTIONS:-". cout<<"ENTER (1/2/3):. cout<<"\n\n\n\t This is a quiz in which you will be asked questions about". /****************************PLAYGAME***********************************/ void playgame() { clrscr().".

sc<49.sc<55.cout<<"\n\n\t\t\tDo you want to continue:(Y/N)".sc--) { clrscr().cout<<"*\n". } case '3': { exit(0). cout<<"\n\n\t\t\t\tPROGRAM TERMINATTING in ".sc<80.cout<<"*".sc++)cout<<"*". cout<<"\n\n\t\t\tDo you want to go to MAINS:(Y/N)". } case '2': { d. for(sc=0. gotoxy(1. if(ch!='y') { clrscr(). cout<<"\t\t\t\t Wrong entry made"<<endl. break. for(sc=1. cout<<"\n\n\t\t\t\tTHANKS". } } break.cout<<" GUIDED BY:-".scorecard().22).sc<80.cprintf(" S. textcolor(WHITE).JHA:-").sc).sc<49.28). for(sc=1.sc++)cout<<"*".} for(sc=0. cout<<sc<<" sec \a".gotoxy(36. for(sc=2. delay(400).5).int sc.sc>0.cout<<" PROGRAMMED BY:-". cout<<"\n\n\t\t\tDo you want to enter again :(Y/N)". ch=getch(). if(ch!='y') { for(sc=3. } break.K.s=58. } default: { clrscr().25 ). ch=getch().sc++){gotoxy(80.} gotoxy(35.sc++){gotoxy(1. break. } } } end().sc++) { 13 .sc). delay(1500). ch=getch(). } /********************************END********************************/ void end() { clrscr(). gotoxy(41.

cprintf(" Anjali"). textcolor(10).gotoxy(sc.cprintf(" Pallavi Gautam").9).cout<<"---------------------.31).cprintf(" Amar Kumar Prasad"). } 14 .gotoxy(sc. } delay(2000). textcolor(4).41).if(sc%2==0&&s>29) { textcolor(14). textcolor(11).gotoxy(sc.gotoxy(sc.cprintf(" Arti").37).gotoxy(sc.gotoxy(s.45).cprintf(" Perwez"). textcolor(3). exit(0).8).39).cprintf("THANKS FOR PLAYING "). textcolor(6).33). textcolor(7).43). delay(50). textcolor(5). gotoxy(s-1.cprintf(" Kundan Kumar"). } textcolor(2).gotoxy(sc.cprintf(" Kumar Shivam").gotoxy(sc. s--.cprintf(" Viswanath Gupta").gotoxy(sc.".35).