Вы находитесь на странице: 1из 31
2014-2015 Computer Science Project Ashwin Francis
2014-2015
Computer Science
Project
Ashwin Francis
1. Certificate 2. Declaration 3. Acknowledgement 4. Introduction to c++ 5. Introduction to Project 6.

1. Certificate

2. Declaration

3. Acknowledgement

4. Introduction to c++

5. Introduction to Project

6. Codings

7. Outputs

8. Bibliography

This is to certify that the proj ect entitled “ QUIZ GAME ” is a

This is to certify that the project entitled “QUIZ GAME” is a record of bonafide work carried out by Ashwin Francis 12 th A”.In partial fulfilment of the requirements in COMPUTER SCIENCE prescribed by CBSE for CBSE BOARD 2014-2015 in the school Kendriya Vidyalaya Gole Market,New Delhi 110001.

DATE

INTERNAL

EXAMINER

PRINCIPAL

EXTERNAL

EXAMINER

We hereby declare that the project work entitled “ QUIZ GAME “. Submitted to KENDRIYA

We hereby declare that the project work entitled QUIZ GAME“. Submitted to KENDRIYA VIDYALAYA GOLE MARKET, NEW DELHI for theSubject of “COMPUTER SCIENCE“. Under the guidance of Mrs.Neera Singhal, PGT(COMP Sc.), Is a record of original work done by us.We further Declare that this project record or any part of this has not been Submitted elsewhere for any other class.

DATE

MEMBERS

PLACE

We wish to express our sincere thanks to Mr. DHIR SINGH Principal,Kendriya Vidyalaya Gole Market,

We wish to express our sincere thanks to Mr. DHIR SINGH Principal,Kendriya Vidyalaya Gole Market, New Delhi for guiding us to cause the successful outcome of this project work.

We wish to express our deep & profound sense of gratitude to our guide/teacher Mrs.Neera Singhal, PGT(COMP Sc.), For her expert help &valuable guidance, comments and suggestions.

We also place on record, our sincere Gratitude to one and all who ,Directly or Indirectly ,Have Lent their helping hand in this venture.

C++ is a programming Language Developed by Bjarne Stroustrup. It was originally named as C

C++ is a programming Language Developed by Bjarne Stroustrup. It was originally named as C with classes, was renamed as C++ in 1983.It is regarded as an intermediate-level language, as it comprises both high-level and low-level language features. Its application domains include systems software, application software, device drivers, embedded software, highperformance server and client applications, and entertainment software such as video games. C++ continues to be used and is one of the preferred programming languages to develop professional applications

The Features of C++ as a Language

Now that all the necessary theory has been covered, now it is possible to

explain what C++ has to offer as a programming language. C++

• is

an open source ISO-standardized language.

For a time, C++ had no official standard and was maintained by a defacto

standard, however since 1998, C++ is standardized by a committee of

the ISO.

• is

a compiled language.

C++ compiles directly to a machine's native code, allowing it to be one

of the fastest languages in the world, if optimized.

• supports

both static and dynamic type checking.

C++ allows type conversions to be checked either at compile-time or

at run-time, again offering another degree of flexibility. Most C++ type

checking is, however, static.

is portable.

As one of the most frequently used languages in the world and as an open language, C++ has a wide range of compilers that run on many different platforms that support it.Code that exclusively uses C++'s standard library will run on many platforms with few to no changes.

Quiz game is a very popular General Knowledge Game. The quiz game increases the IQ

Quiz game is a very popular General Knowledge Game. The quiz game increases the IQ knowledge of the player. It is used to check the knowledge within us.

The provided source code is the simple Quiz game programmed implementing C language. In this program several question are provided to the player. The players are provided with 4 options in it. Player is all need to choice the suitable option from the 4 option available in the screen. The player needs to type either A, B, C, or D according to the suitable answer provided in it.

The player will score the points with each correct answer provided.

#include<iostream.h>

#include<fstream.h>

#include<ctype.h>

#include<string.h>

#include<conio.h>

#include<stdlib.h>

#include<stdio.h>

class quiz

{

public :

void set1();

void ques1();

void ques2();

void ques3();

void ques4();

void ques5();

void fifty1();

void fifty2();

void fifty3();

void fifty4();

void fifty5();

}s1;

long int pts;

int t=0,flag=0;

char ans[1],w;

fifty1(); void fifty2(); void fifty3(); void fifty4(); void fifty5(); }s1; long int pts; int t=0,flag=0; char

fstream f1;

void main()

{

clrscr();

int n;

char name[30],ch;

fstream f1;

cout<<"\n\t\t\t\t THIS IS A QUIZ GAME\n\n\tCREATED BY \n\t\tAMAN ROY\n\t\tSHOBHIT GUPTA\n\t\tVIMAL KUMAR \n\nPRESS ENTER TO PLAY";

getch();

menu:

clrscr();

cout<<"\t\t\t\tMENU\n1.Play game\n2.View game data\n\nEnter your choice: ";

cin>>n;

if(n==2)

{

f1.open("Game.txt",ios::in);

if(!f1)

{

cout<<"No Data\n\n\nPRESS ENTER";

getch();

goto menu;

}

else

{

f1.seekg(0);

while(!f1.eof())

{

f1.get(ch);

cout<<ch;

}

f1.close();

cout<<"\n\n\nPRESS ENTER";

getch();

goto menu;

}

}

else

{

cout<<"\n\n\n FIRST ANSWER THE ELIGIBLE QUESTION TO PLAY THE GAME";

cout<<"\n\nEnter the name:-";

gets(name);

f1.open("Game.txt",ios::out);

f1<<name<<" ";

getch();

s1.set1();

label:

cout<<"\ n \ n \ t\ t\ tTHANK YOU FOR USING THIS SOFTWARE\ n \ t THIS SOFTWARE IS CREATED BY THE STUDENTS OF K. V. GOLE MARKET.\n\t\t\t\tPLEASE DONT COPY ";

getch();

}

}

//*************** END OF MAIN **********************

//******** SET 1

void quiz::set1()

{

clrscr();

cout<<"\n This is your eligibility question ";

cout<<"\n\n\n\nIn computer,what is 1gigabyte?";

cout<<"\n(a)1024*2 bytes"<<"\t(b)1024*1024*1024 bytes";

cout<<"\n(c)1024*3 bytes"<<"\t(d)NONE OF THESE";

char rs[]="b";

cout<<"\nEnter your answer :- ";

cin>>ans;

t=strcmp(ans,rs);

if(t==0)

{

clrscr();

cout<<"\nYou have qualified";

cout<<"\n***********************************";

cout<<"\n**WELCOME TO THIS GRAND QUIZ SHOW**";

cout<<"\n***********************************";

cout<<"\n\n\n\nHERE YOU WILL BE ASKED A QUESTION & FOUR OPTIONS ";

cout<<"\nWILL BE THERE, IN WHICH THREE ARE WRONG AND ONLY ONE";

cout<<"\nIS CORRECT.YOU HAVE TO GIVE THE CORRECT ANSWER ";

cout<<"\nYOU HAVE A 50 - 50 HELP LINE IN WHICH THERE WILL BE ";

cout<<"\nONLY TWO OPTIONS OF WHICH ONLY ONE IS CORRECT. YOU";

cout<<"\nHAVE TO GIVE THE CORRECT ANSWER.ANY WRONG ANSWER MEANS YOU ";

cout<<"\nFINISH THE GAME THERE ONLY. "; cout<<"\n******** YOU CAN TAKE ONLY THREE HELP LINES *********";

cout<<"\n\n\n\n\nPRESS ENTER TO START THE GAME ";

getch();

s1.ques1();

}

else

{

cout<<"\aWRONG ANSWER !!!!\a";

cout<<"\n\n\t\t BETTER LUCK NEXT TIME ";

getch();

}

}

//************** QUESTION 1

void quiz::ques1()

{

clrscr();

cout<<"\nWhat do you mean by Hexadecimal in computer?";

cout<<"\n(a)With a base of 16"<<"\t(b)With a base of 6";

cout<<"\n(c)With a base of 8"<<"\t(d)NONE OF THESE";

char rs[]="a";

cout<<"\nDO YOU WANT 50/50 LIFELINE (Y/N) ";

cin>>w;

if(w=='Y'|| w=='y')

{

flag++;

s1.fifty1();

}

cout<<"\n Please give your answer :- ";

cin>>ans;

t=strcmp(ans,rs);

if(t==0)

{

pts=1000;

cout<<" YOUR SCORE IS :- "<<pts;

f1<<"\n"<<pts;

f1.close();

cout<<"\nPRESS ANY KEY FOR THE NEXT QUESTION ";

getch();

s1.ques2();

}

else

{

cout<<"\aWRONG ANSWER !!!!\a";

getch();

}

}

void quiz::fifty1()

{

clrscr();

cout<<"\nWhat do you mean by Hexadecimal in computer?";

cout<<"\n(a)With a base of 16"<<"\t(b)With a base of 6";

}

//******** QUESTION 2

void quiz::ques2()

{

clrscr();

cout<<"\nWho has written the book 'DIVINE LIFE?";

cout<<"\n(a)Charles Dickens"<<"\t(b)Dante Alighieri";

cout<<"\n(c)Swami Sivananda"<<"\t(d)Karl Marx";

char rs[]="c";

cout<<"\nDO YOU WANT 50/50 LIFELINE (Y/N)";

cin>>w;

if(w=='Y'||w=='y')

{

flag++;

s1.fifty2();

}

cout<<"\n Please give your answer ";

cin>>ans;

t=strcmp(ans,rs);

if(t==0)

{

pts=2000;

cout<<" YOUR SCORE IS :- "<<pts;

f1.open("Game.txt",ios::app);

f1<<"\n"<<pts;

f1.close();

cout<<"\nPRESS ANY KEY FOR THE NEXT QUESTION ";

getch();

s1.ques3();

}

else

{

cout<<"\aWRONG ANSWER !!!!\a";

}

}

void quiz::fifty2()

{

clrscr();

cout<<"\nWho has written the book 'DIVINE LIFE?";

cout<<"\n(c)Swami Sivananda"<<"\t(d)Karl Marx";

}

//******Question 3

void quiz::ques3()

{

clrscr();

cout<<"\nWho has written the book'ONE LIFE'?";

cout<<"\n(a)Christian Barnard"<<"\t(b)Wendell Wilkie";

cout<<"\n(c)William Wordsworth"<<"\t(d)Charles Darwin";

char rs[]="a";

cout<<"\nDO YOU WANT 50/50 LIFELINE(Y/N)";

cin>>w;

if(w=='Y'||w=='y')

{

flag++;

s1.fifty3(); }

cout<<"\n Please give your answer ";

cin>>ans;

t=strcmp(ans,rs);

if(t==0) {

pts=3000;

cout<<" YOUR SCORE IS :- "<<pts;

cout<<"\nPRESS ANY KEY FOR THE NEXT QUESTION ";

f1.open("Game.txt",ios::app);

f1<<"\n"<<pts;

f1.close();

getch();

s1.ques4();

}

else

{

cout<<"\aWRONG ANSWER !!!!\a";

}

}

void quiz::fifty3()

{

clrscr();

cout<<"\nWho has written the book'ONE LIFE'?";

cout<<"\n(a)Christian Barnard"<<"\n(c)William Wordsworth";

}

//**********Question 4

void quiz::ques4()

{

clrscr();

cout<<"\nWhich game is associate with 'YONEX CUP'?";

cout<<"\n(a)Golf"<<"\t(b)Baseball";

cout<<"\n(c)Yatch Racing"<<"\t(d)Badminton";

char rs[]="d";

if(flag<3)

{

flag++;

cout<<"\nDO YOU WANT 50/50 LIFELINE(Y/N)";

cin>>w;

if(w=='Y'||w=='y')

{

flag++;

s1.fifty4();

}

}

cout<<"\n Please give your answer ";

cin>>ans;

t=strcmp(ans,rs);

if(t==0)

{

pts=5000;

cout<<" YOUR SCORE IS :- "<<pts;

cout<<"\nPRESS ANY KEY FOR THE NEXT QUESTION ";

f1.open("Game.txt",ios::app);

f1<<"\n"<<pts;

f1.close();

getch();

s1.ques5();

}

else

{

cout<<"\aWRONG ANSWER !!!!\a";

}

}

void quiz::fifty4()

{

clrscr();

cout<<"\nWhich game is associate with 'YONEX CUP'?";

cout<<"\n(a)Golf"<<"\t(d)Badminton";

}

//Question 5

void quiz::ques5()

{

clrscr();

cout<<"\nWho invented 'MECHANICAL CLOCK'?";

cout<<"\n(a)C.Hugyens\t(b)Samuel Colt";

cout<<"\n(c)Hsing and Ling-Tsan\t(d)Wilhelm Roentgen";

char rs[]="c";

if(flag<3)

{

cout<<"\nDO YOU WANT 50/50 LIFELINE(Y/N)";

cin>>w;

if(w=='Y'||w=='y')

{

flag++;

s1.fifty5();

}

}

cout<<"\n Please give your answer ";

cin>>ans;

t=strcmp(ans,rs);

if(t==0)

{

pts=10000;

cout<<" YOUR SCORE IS :- "<<pts;

f1.open("Game.txt",ios::app);

f1<<"\n"<<pts;

f1.close();

getch();

clrscr();

cout<<"\n\t\t\t**********************************************";

cout<<"\n\t\t\tCONGRATULATIONS YOUHAVE COMPLETED THE FULL SET ";

cout<<"\n\t\t\t**********************************************";

}

else

{

cout<<"\aWRONG ANSWER !!!!\a";

}

}

void quiz::fifty5()

{

clrscr();

cout<<"\nWho invented 'MECHANICAL CLOCK'?";

cout<<"\n\t(b)Samuel Colt\n(c)Hsing and Ling-Tsan";

}

HELP FROM INTERNET INFORMATION FROM BOOKS HELP FROM TEACHERS

HELP FROM INTERNET

HELP FROM INTERNET INFORMATION FROM BOOKS HELP FROM TEACHERS

INFORMATION FROM BOOKS

HELP FROM INTERNET INFORMATION FROM BOOKS HELP FROM TEACHERS

HELP FROM TEACHERS

HELP FROM INTERNET INFORMATION FROM BOOKS HELP FROM TEACHERS