Documente Academic
Documente Profesional
Documente Cultură
#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);
gotoxy(23,5);
cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
gotoxy(10,9);
gotoxy(10,13);
gotoxy(10,14);
cout<<"# [Roll:- 11]";
gotoxy(50,13);
gotoxy(50,14);
gotoxy(10,18);
getch();
clrscr();
do
gotoxy(15,1);
cout<<"1. PLAY";
gotoxy(15,2);
cout<<"2. HIGHSCORE";
gotoxy(15,3);
gotoxy(15,4);
gotoxy(15,5);
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)
}
else if(tot<temp)
getch();
break;
case 2:
highscore();
break;
case 3:
previous();
break;
case 4:
clrhscore();
break;
case 5:
exit(0);
default:
cout<<"wrong choice"<<endl;
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<<"+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);
puts(y);
return;
}
void previous()
gotoxy(5,9);
gotoxy(5,10);
cout<<"NAME :- ";
puts(p.d);
gotoxy(5,11);
cout<<"PID :- ";
cout<<p.c[20];
gotoxy(5,12);
cout<<tot;
c=tot/4;
gotoxy(5,13);
cout<<c;
d=5-c;
gotoxy(5,14);
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;