Sunteți pe pagina 1din 11

SOURCE CODE

#include<fstream.h>

#include<conio.h>

#include<stdio.h>

#include<process.h>

int choice,i,temp,score,tot,c,d;

float per;

char ch,z[3],a[200],op;

char b[]={'b','a','c','a','a'};

void play();

void submit(char);

void previous();

void highscore();

void clrhscore();

class player

public:
int c[20];

char d[20];

}p;

void main()

clrscr();

gotoxy(23,1);

cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";

gotoxy(30,3);

cout<<"((("<<" "<<"GK QUIZ"<<" "<<")))";

gotoxy(23,5);

cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";

gotoxy(10,9);

cout<<" SUBMITTED BY:- ";

gotoxy(10,13);

cout<<"# [Akash Kumar]";

gotoxy(10,14);
cout<<"# [Roll:- 11]";

gotoxy(50,13);

cout<<"# [Harsh Singh]";

gotoxy(50,14);

cout<<"# [Roll:- 28]";

gotoxy(10,18);

cout<<"press any key to start quiz"<<endl;

getch();

clrscr();

do

gotoxy(15,1);

cout<<"1. PLAY";

gotoxy(15,2);

cout<<"2. HIGHSCORE";

gotoxy(15,3);

cout<<"3. PREVIOUS PERFORMANCE";

gotoxy(15,4);

cout<<"4. CLEAR HIGHSCORE";

gotoxy(15,5);

cout<<"5. EXIT(0)"<<endl<<"enter choice"<<" ";


cin>>choice;

switch(choice)

case 1:

play();

tot=score;

ofstream ho("h.txt",ios::nocreate||ios::out);

ifstream who("h.txt",ios::in);

who.getline(z,2,'$');

temp=((z[1])+(10*z[2]));

if(tot>temp)

ho<<tot;

cout<<"highscore"<<endl;

else if(tot>=temp)

cout<<"new highscore "<<tot;

}
else if(tot<temp)

cout<<"encountering break staement"<<endl;

getch();

break;

case 2:

highscore();

break;

case 3:

previous();

break;

case 4:

clrhscore();

break;

case 5:

exit(0);

default:
cout<<"wrong choice"<<endl;

cout<<"go to main menu? (Y/N)";

cin>>ch;

getch();

clrscr();

}while(ch=='y');

cout<<"over";

getch();

void play()

ifstream fin("qu.txt");

cout<<"PLAYER ID"<<endl;

cin>>p.c[20];

cout<<"PLAYER NAME"<<endl;

gets(p.d);

cout<<"player created!"<<endl;

getch();
clrscr();

while(!fin.eof())

gotoxy(3,7);

cout<<"NAME :- ";

puts(p.d);

gotoxy(53,7);

cout<<"PID :- ";

cout<<p.c[20];

gotoxy(3,8);

cout<<"question :- "<<i+1;

gotoxy(53,8);

cout<<"[score "<<score<<"]"<<endl;

gotoxy(3,9);

cout<<"===========================================================";

fin.getline(a,250,'!');

gotoxy(1,11);

puts(a);

cout<<"option "<<endl;
cin>>op;

submit(op);

getch();

clrscr();

cout<<"over2"<<endl;

return;

void submit(char r)

if(r==b[i])

cout<<"correcr answer !"<<endl;

cout<<"+4"<<endl;

score+=4;

else

cout<<"incorrect 0";
i++;

return;

void highscore()

char y[31];

ifstream i("h.txt");

i.getline(y,4,'p');

gotoxy(5,15);

cout<<"High Score is ";

puts(y);

return;

}
void previous()

gotoxy(5,9);

cout<<"PREVIOUS PLAYER DETAILS";

gotoxy(5,10);

cout<<"NAME :- ";

puts(p.d);

gotoxy(5,11);

cout<<"PID :- ";

cout<<p.c[20];

gotoxy(5,12);

cout<<"TOTAL SCORE :- ";

cout<<tot;

c=tot/4;

gotoxy(5,13);

cout<<"NO OF CORRECT ANSWERS :- ";

cout<<c;

d=5-c;

gotoxy(5,14);

cout<<"NO OF WRONG ANSWERS :- ";

cout<<d;

per=(tot/20)*100;

gotoxy(5,15);
cout<<"PERCENTAGE OF CORRECT ANS ;- ";

cout<<per<<"% ";

void clrhscore()

ofstream k("h.txt",ios::nocreate||ios::out);

k<<"00";

gotoxy(5,15);

cout<<"HIGHSCORE CLEARED"<<endl;

return;

S-ar putea să vă placă și