Computer Investigatory Project CBSE Class 12
Computer Investigatory Project CBSE Class 12
1|Page
BONAFIDE CERTIFICATE
Certified that this is a bonafide record of project work done by Sidharth M of Kendriya Vidyalaya No.2, Pondicherry University Campus, Kalapet, Puducherry during the academic year 2013-2014.
Principals signature
2|Page
ACKNOWLEDGEMENT
I wish to express my deep gratitude and sincere thanks to Principal, Mr. Sampath Kumar, Kendriya Vidyalaya No.2, Pondicherry, for his encouragement and for all the facilities that he provided for this project work. I sincerely appreciate this magnanimity by taking me into his fold for which I shall remain indebted to him. I extend my hearty thanks to Mr. Praveen Kumar , Computer Science teacher, who guided me to the successful completion of this project. I take this opportunity to express my deep sense of gratitude for her invaluable guidance, constant encouragement, constructive comments, sympathetic attitude and immense motivation, which has sustained my efforts at all stages of this project work. I cant forget to offer my sincere thanks to my classmates who helped me to carry out this project work successfully & for their valuable advice & support, which I received from them time to time.
3|Page
SOURCE CODE:
//THE MEMORY GAME #include<graphics.h> #include<dos.h> #include<fstream.h> #include<conio.h> #include<stdlib.h> int a[10],c[10],point=0,flag=1,p[50],s; char ans='y',con; int compare(int); int mem_game (int); void rec(); void main() { clrscr(); int ch; int gdriver = DETECT, gmode; initgraph(&gdriver, &gmode, "c:\\TC\\BGI"); start: clrscr(); settextstyle(1,0,3); setcolor(1); outtextxy(125,100,"THE MEMORY GAME"); outtextxy(60,175,"1.Play Game 2.High Scores 3.Instructions 4.Exit"); cin>>ch; switch(ch)
4|Page
{ case 1: { for(int y=3;y<10;y++) { clrscr(); cout<<"Level "<<y-2<<endl;sleep(1); if(y==3)point=0; mem_game(y); clrscr(); s=compare(y); if(s==0)goto start; mem_game(y); clrscr(); s=compare(y); if(s==0)goto start; clrscr(); cout<<"Level "<<y-2<<" cleared!"<<endl; sleep(1); clrscr(); } Cout<<Thank you for playing the game !<<endl; sleep(1); break; } case 2: { int big,pos,tmp,i=0; fstream pt("Hscore.txt",ios::in); while(!pt.eof()) { pt>>p[i];
5|Page
i++; } for(int j=0;j<i;j++) { big=p[i]; pos=i; for(int k=j+1;k<i;k++) { if(p[k]>big) {big=p[k]; pos=k;} } tmp=p[j]; p[j]=p[pos]; p[pos]=tmp; } clrscr(); for(j=0;j<i;j++) cout<<j+1<<" . "<<p[j]<<endl; sleep(3); goto start; } case 3: clrscr(); cout<<"\tHello. This is a very simple. A list of numbers will be printed and the player has to keep them in mind and reproduce them when asked.\nFor every correct answer the player gets awarded 10 points .If the player makes one wrong input he/she is out.\nHave Fun! "<<endl; cout<<"\n\nEnter y to continue"<<endl; cin>>con; if(con=='y'||con=='Y') goto start; else goto start; case 4: clrscr(); 6|Page
break; default : clrscr(); cout<<"Wrong choice! Restarting";sleep(2); goto start; } clrscr(); getch(); } int mem_game(int n) { randomize(); int x; for(int i=0;i<n;i++) { x=random(9)+1; c[i]=x; clrscr(); switch(x) { case 1:rec();settextstyle(1,0,3);outtextxy(225,115,"1");sleep(1);clrscr();rec();break; case 2:rec();settextstyle(1,0,3);outtextxy(291,115,"2");sleep(1);clrscr();rec();break; case 3:rec();settextstyle(1,0,3);outtextxy(357,115,"3");sleep(1);clrscr();rec();break; case 4:rec();settextstyle(1,0,3);outtextxy(225,181,"4");sleep(1);clrscr();rec();break; case 5:rec();settextstyle(1,0,3);outtextxy(291,181,"5");sleep(1);clrscr();rec();break; case 6:rec();settextstyle(1,0,3);outtextxy(357,181,"6");sleep(1);clrscr();rec();break; case 7:rec();settextstyle(1,0,3);outtextxy(225,247,"7");sleep(1);clrscr();rec();break; case 8:rec();settextstyle(1,0,3);outtextxy(291,247,"8");sleep(1);clrscr();rec();break; case 9:rec();settextstyle(1,0,3);outtextxy(357,247,"9");sleep(1);clrscr();rec();break; }
7|Page
} return 0; } int compare(int n) { int i=0; cout<<"Enter the numbers in the correct order : "<<endl; while(i<n) { cin>>a[i]; if(a[i]!=c[i]) { cout<<"Wrong!!! GAME OVER!\n"; cout<<"Score : "<<point; flag=0; fstream pt("Hscore.txt",ios::out|ios::app); pt<<point<<endl; pt.close(); sleep(4); return 0; } else point+=10; i++; } return 1; }
8|Page
9|Page
BIBLIOGRAPHY:
www.google.com www.programmingsimplified.com www.youtube.com
10 | P a g e