Avanish Pandey Bca Project Quiz Game in C
Avanish Pandey Bca Project Quiz Game in C
Avanish Pandey Bca Project Quiz Game in C
On
VARANASI
1
2
DECLARATION BY THE CANDIDATE
AVANISH PANDEY
BCA – VI SEMESTER
ROLL NO.: 11419407109
3
ACKNOWLEDGEMENT
I would also like to thank my project mentor and all the people who
provided me with the facilities being required and conductive conditions
for my BCA – 3rd year project.
Thank you
AVANISH PANDEY
Yours sincerely,
Bhavesh Karwal
4
INDEX
TOPIC PAGE NO.
Declaration
05
Certificate
Abstract
Introduction 15
References 36
CONTENTS
1 Introduction 6
5
2 Objectives 7
3 Features 7
8 Coding 18-38
9 Output 39-41
12 References 44
6
ABSTRACT
a binary file by
file.
7
various topics include Science, Mathematics, GK etc the user can add
and modify
8
ABOUT THE COMPANY
HISTORY:
9
FOUNDER DAVID ANDREWS:
Mr. David W. Andrews serves as the Chief Executive Officer of Xchanging UK Ltd.,
(alternate name Xchanging Ltd). Mr. Andrews served as Senior Adviser of Xchanging
PLC. He served as Chief Executive Officer and Member of Management Board at
Xchanging PLC. He founded Xchanging PLC in 1999. Mr. Andrews served as an
Executive Chairman and Chief Executive Officer of Cambridge Solutions, Ltd., from
January 12, 2009 to February 9th 2011. He built up Accenture's outsourcing business
and had responsibility for managing major technology replacement programmes in
Europe. In 1990, he led the successful Accounting outsourcing for British Petroleum -
the first of its kind in the world. Then in 1992, he led the massive outsourcing
arrangement for the London Stock Exchange. In 1994, Mr. Andrews relocated to Paris
to take responsibility for Accenture's business in West Europe. Over three years, he
moved West Europe from the worst to the most profitable of the 9 Accenture regions
worldwide and was also responsible for the implementation of the Xetra trading system
at Deutsche Börse. Before joining Accenture, he managed a major programme of
hospital refurbishment and health care infrastructure renewal in Congo. Mr. Andrews
serves as the Chairman of Xchanging Transaction Bank GmbH, Frankfurt /Main. His
Other Appointments includes Ins-Sure Services Ltd., Together HR Services Ltd.,
Xchanging Ltd. and Xchanging Procurement Service Ltd. He serves as a Director of
Xchanging B.V. He has been an Additional Director of Cambridge Solutions, Ltd.
since January 12, 2009. He served as a Member of the Supervisory Board of Deutsche
Börse AG from May 14, 2003 to June 3, 2007. He served as a Director of Xchanging
PLC. He is a Fellow of the Institute of Chartered Accountants and is a William Pitt
fellow of Pembroke College Cambridge. Mr. Andrews has an MA in Finance and
Administration from Sheffield University.
10
1. INTRODUCTION
3.1 INTRODUCTION
11
3.2 OBJECTIVE
1. The main objective of the Quiz application is to overcome all the
drawbacks of the old Quiz Game.
3.3 FEATURES
3. Easy to modify
12
2. MATERIALS AND METHODOLOGY
4.1.1 HISTORY:
14
It was developed to overcome the problems of previous languages such as
B, BCPL, etc.
Bjarne Stroustrup, a Danish and British trained computer scientist, began his work on
"C with Classes" in 1979.The idea of creating a new language originated from
Stroustrup's experience in programming for his Ph.D. thesis. Stroustrup found
that Simula had features that were very helpful for large software development, but the
language was too slow for practical use, while BCPL was fast but too low-level to be
suitable for large software development. When Stroustrup started working in AT&T
Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed
computing. Remembering his Ph.D. experience, Stroustrup set out to enhance
the C language with Simula-like features. C was chosen because it was general-
purpose, fast, portable and widely used. Besides C and Simula, some other languages
that inspired him were ALGOL 68, Ada, CLU and ML. At first, the class, derived
class, strong typing, inlining, and default argument features were added to C via
Stroustrup's "C with Classes" to C compiler, Cpre.
In 1983, the name of the language was changed from C with Classes to C++ (++ being
the increment operator in C). New features were added includingvirtual functions,
function name and operator overloading, references, constants, user-controlled free-
store memory control, improved type checking, and BCPL style single-line comments
with two forward slashes (//), as well as the development of a proper compiler for C+
+, Cfront. In 1985, the first edition of The C++ Programming Language was released,
providing an important reference to the language, as there was not yet an official
standard.The first commercial implementation of C++ was released in October of the
same year.Release 2.0 of C++ came in 1989 and the updated second edition of The C+
+ Programming Languagewas released in 1991 New features included multiple
inheritance, abstract classes, static member functions, const member functions, and
protected members. In 1990, The Annotated C++ Reference Manual was published.
This work became the basis for the future standard. Late feature additions
included templates, exceptions, namespaces, new casts, and a Boolean type.
As the C++ language evolved, the standard library evolved with it. The first addition to
the C++ standard library was the stream I/O library which provided facilities to replace
the traditional C functions such as printf and scanf. Later, among the most significant
additions to the standard library, was a large amount of the Standard Template Library.
It is possible to write object oriented or procedural code in the same program in C++.
This has caused some concern that some C++ programmers are still writing procedural
code, but are under the impression that it is object oriented, simply because they are
15
using C++. Often it is an amalgamation of the two. This usually causes most problems
when the code is revisited or the task is taken over by another coder.
C++ continues to be used and is one of the preferred programming languages to
develop professional applications.
1. Procedural Language
2. Fast and Efficient
3. Modularity
4. Statically Type
5. General-Purpose Language
6. Rich set of built-in Operators
7. Libraries with rich Functions
8. Middle-Level Language
9. Portability
10.Easy to Extend
1) Classes: By using classes we can create user defined data types. In
other words the class is the collection of set of data and code. The class
allows us to do some things which are polymorphism, inheritance,
abstraction, encapsulation which are our next features. The objects are the
instances of classes.
2) Inheritance: Inheritance allows one data type to acquire properties of
other data types. Inheritance from a base class may be declared as public,
16
protected, or private. If the access specifier is omitted, a “class” inherits
privately, while a “struct” inherits publicly. This provides the idea of
reusability that means we can add the new features to an existing class
without modifying it.
3) Data Abstraction and Encapsulation: Encapsulation means hiding of
data from the data structures or in other words wrapping up of data in
single entity is known as Encapsulation. In this the data is not accessible to
outside world and only the functions are allowed to access it. When we
want to write the class in which we don’t have the knowledge about the
arguments used to instantiate it then we can use templates in C++.
Abstraction can be defined as the act of representing essential features
without including background details.
4) Polymorphism: it means that the one interface can be used for many
implementation so that object can behave differently for each
implementation. The different types of polymorphism are static (Compile
time) and dynamic (Run time).
5) Dynamic Binding: It means that the linking of a procedure call to code
to be executed in response to the call. A function call associated with a
polymorphic reference depends on the dynamic type that reference. And at
run-time the code matching the object under current reference will be
called.
6) Message Passing: An object oriented program consists of the set of
objects that communicate with each other. objects communicate with one
17
another by sending and receiving information much the same way as
people pass messages to one another. The concept of message passing
makes it easier to direct model or simulate their real world counterparts.
4.2
18
SYSTEM REQUIRMENTS
Following hardware specifications and software are required to run this project:
Following hardware specifications and software are required to run this project:
2) Turbo C3 compiler.
4.3
SOFTWARE DESCRIPTION
19
low price and a fast compiler, but was not as successful because of
competition in the C compiler market.
The first version was released on May 13, 1987, and it offered the
first-ever edit-compile-run environment for software development on IBM
PCs. Turbo C was not originally developed by Borland but was bought
from Bob Jervis and was initially called Wizard C. Turbo Pascal did not
have pull-down menus before this time, and it was only on its fourth
version that it received a face lift to look like Turbo C.
20
eventually evolved into Turbo C++, then into Borland C++ and, finally,
into C++ Builder.
Turbo C features:
22
Version 4.0 was released in November 1993 and was notable (among other things) for
its robust support of templates. In particular, Borland C++ 4 was instrumental in the
development of theStandard Template Library, expression templates, and the first
advanced applications of template metaprogramming. With the success of the Pascal-
evolved product Delphi, Borland ceased work on their Borland C++ suite and
concentrated on C++Builder for Windows. C++Builder shared Delphi's front-end
application framework, but retained the Borland C++ back-end compiler. Active
development on Borland C++/Turbo C++ was suspended until 2006.
23
3. DESIGN AND IMPLEMENTATION
5.1 DESIGN
The Quiz Game was conducted manually. The Quiz Master had
a book of questions which contained qustionsquestions related to
various topics.
24
5.2 IMPLEMENTATION
QUIZ GAME
QUIZ GAME
PLAY EDIT
ADD QUESTIONS
COMPUTERS
DELETE
RETURN
MODIFY
MATHS
GENERAL
SCIENCE
25
D.B.M.S
Fig (1)
26
The stages of "The Waterfall Model"
27
Requirement Analysis & Definition:
All possible requirements of the system to be developed are captured
in this phase. Requirements are set of functionalities and constraints that
the end-user (who will be using the system) expects from the system. The
requirements are gathered from the end-user by consultation, these
requirements are analyzed for their validity
28
CODING
//c
proj
ect
on
quiz
game
by
deep
ak
shar
ma
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
void show_record();
void reset_score();
void help();
void edit_score(float,char[]);
int main()
{
int countr,r,r1,count,i,n;
float score;
char choice;
char playername[20];
mainhome:
printf("\t\t\t << QUIZ GAME >>\n");
printf("\n\t\
t****************************************");
29
printf("\n\t\t\t WELCOME\n ");
printf("\n\t\t\t to\n ");
printf("\n\t\t\t THE QUIZ GAME ");
printf("\n\t\t");
printf("\n\t\
t****************************************");
printf("\n\t\t BECOME RICH EARN UPTO 1 MILLION
$ ;-) ");
printf("\n\t\
t****************************************");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > Press V to view the highest score ");
printf("\n\t\t > Press R to reset score");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\
n\n");
choice=toupper(getch());
if(choice=='V')
{
system("cls");
show_record();
system("cls");
goto mainhome;
}
30
else if(choice=='H')
{
system("cls");
help();
getch();
system("cls");
goto mainhome;
}
else if(choice=='R')
{
system("cls");
reset_score();
getch();
goto mainhome;
}
else if (choice=='Q')
{
exit(1);
}
else if(choice=='S')
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t\tResister your name:");
gets(playername);
31
system("cls");
printf("\n *********** Welcome %s to C Program Quiz
Game *****************",playername);
printf("\n\n Here are some tips you might wanna know
before playing:");
printf("\n
******************************************************
**************************");
printf("\n >> There are 2 rounds in this Quiz
Game,WARMUP ROUND & CHALLANGE ROUND");
printf("\n >> In warmup round you will be asked a total of
3 questions to test your");
printf("\n general knowledge. You are eligible to play the
game if you give atleast 2");
printf("\n right answers, otherwise you can't proceed
further to the Challenge Round.");
printf("\n >> Your game starts with CHALLANGE
ROUND. In this round you will be asked a");
printf("\n total of 10 questions. Each right answer will be
awarded with 10 points!");
printf("\n By this way you can score upto
100 :-) :-):-):-):-):-):-)!!!!!..........");
printf("\n >> You will be given 4 options and you have to
press A, B ,C or D for the");
printf("\n right option.");
printf("\n >> You will be asked questions continuously, till
right answers are given");
32
printf("\n >> No negative marking for wrong answers!");
printf("\n\n\t!!!!!!!!!!!!! ALL THE BEST !!!!!!!!!!!!!");
printf("\n\n\n Press Y to start the game!\n");
printf("\n Press any other key to return to the main
menu!");
if (toupper(getch())=='Y')
{
system("cls");
goto home;
}
else
{
system("cls");
goto mainhome;
}
home:
system("cls");
count=0;
for(i=1;i<=3;i++)
{
r1=i;
switch(r1)
33
{
case 1:
printf("\n\nA collecion of 8 bits are called?");
printf("\n\nA.bit\t\tB.word\n\nC.byte\t\
tD.record");
if (toupper(getch())=='C')
{
printf("\n\nCorrect!!!");
count++;
getch();
system("cls");
break;
}
else
{
printf("\n\nWrong!!! The correct answer is
C.byte");
getch();
system("cls");
break;
}
case 2:
printf("\n\nWhich of the following is a
Palindrome number?");
printf("\n\nA.42042\t\tB.101010\n\nC.23232\t\
34
tD.01234");
if (toupper(getch())=='C')
{
printf("\n\nCorrect!!!");
count++;
getch();
system("cls");
break;
}
else
{
printf("\n\nWrong!!! The correct answer is
C.23232");
getch();
system("cls");
break;
}
system("cls");
case 3:
printf("\n\n\nWhich of the following is most
oriented toward scientific programming ?");
printf("\n\nA.Cobol\t\tB.Fortran\n\nC.c++\t\
tD.Basic");
35
if (toupper(getch())=='B')
{
printf("\n\nCorrect!!!");
count++;
getch();
system("cls");
break;
}
else
{
printf("\n\nWrong!!! The correct answer is
B.Fortran");
getch();
system("cls");
break;
}
}
}
if(count>=2)
{
goto test;
}
36
else
{
system("cls");
printf("\n\nSORRY YOU ARE NOT ELIGIBLE
TO PLAY THIS GAME, BETTER LUCK NEXT TIME");
getch();
goto mainhome;
}
test:
system("cls");
printf("\n\n\t*** CONGRATULATION %s you are eligible
to play the Game ***",playername);
printf("\n\n\n\n\t!Press any key to Start the Game!");
if(toupper(getch())=='p')
{
goto game;
}
game:
countr=0;
for(i=1;i<=10;i++)
{
system("cls");
r=i;
37
switch(r)
{
case 1:
printf("\n\nAll are the example of input devices
Except a:");
printf("\n\nA.Scanner\t\tB.Mouse\n\nC.Printer\t\
tD.Keyboard");
if (toupper(getch())=='C')
{
printf("\n\nCorrect!!!");countr++;getch();
break;
getch();
}
else
{
printf("\n\nWrong!!! The correct answer is
C.Printer");
getch();
goto score;
break;
}
case 2:
printf("\n\n\nWhat kind of file extension .mpg?,");
printf("\n\nA.Movie file \t\tB.Text file\n\nC.Image
38
file\t\tD.Audio file");
if (toupper(getch())=='A')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;
}
else
{
printf("\n\nWrong!!! The correct answer is A.Movie
file");
getch();
goto score;
break;
}
case 3:
printf("\n\n\nA DVD is an example of a/an.. ");
printf("\n\nA.Magnetic disk\t\tB.Hard disk\n\
nC.Output device\t\tD.Optical disk");
if (toupper(getch())=='D')
{
printf("\n\nCorrect!!!");
countr++;
getch();
39
break;
}
else
{
printf("\n\nWrong!!! The correct answer is
D.Optical disk");
getch();
goto score;
break;
}
case 4:
printf("\n\n\nWho is he founder of facebook?");
printf("\n\nA.Mark zuckerburg\tB.Tesla\n\
nC.Steve jobs\t\tD.Bill gates");
if (toupper(getch())=='A')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;
}
else
{
printf("\n\nWrong!!! The correct answer is A.Mark
zuckerburg");
getch();
40
goto score;
break;
}
case 5:
printf("\n\n\nWhich of he following is a web
browser?");
printf("\n\nA.Dreamweaver\tB.Netscape navigator\
n\nC.Maya\t\tD.Flash");
if(toupper(getch())=='B')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;}
else
{
printf("\n\nWrong!!! The correct answer is
B.Netscape navigator");
getch();
goto score;
break;
}
case 6:
printf("\n\n\nWhat kind of file extension .bak?,");
printf("\n\nA.Backup file \t\tB.Text file\n\nC.Image
file\t\tD.Audio file");
41
if (toupper(getch())=='A')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;}
else
{
printf("\n\nWrong!!! The correct answer is
A.Backup file");
getch();
goto score;
break;
}
case 7:
printf("\n\n\nwhich of he following is a read only
memory storage device ");
printf("\n\nA.Flash drive\t\tB.Hard disk\n\
nC.Floppy disk\t\tD.CDROM");
if(toupper(getch())=='D')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;}
else
42
{
printf("\n\nWrong!!! The correct answer is
D.CDROM");
getch();
goto score;
break;
}
case 8:
printf("\n\n\nThe _____ shows all the web sites any
pages that you have visited one of recent time ");
printf("\n\nA.Hisory list\t\tB.Status bar \n\nC.task
bar\t\tD.record");
if(toupper(getch())=='A')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;}
else
{
printf("\n\nWrong!!! The correct answer is
A.Hisory list");
getch();
goto score;
break;
}
case 9:
43
printf("\n\n\nA 32 bit word computer can access
____ bytes at a time ");
printf("\n\nA.32\t\tB.16\n\nC.8\t\tD.4");
if(toupper(getch())=='C')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;}
else
{
printf("\n\nWrong!!! The correct answer is
C.8");
getch();
goto score;
break;
}
case 10:
printf("\n\n\nWho is the founder of pixar animation?");
printf("\n\nA.Mark zuckerburg\tB.Tesla\n\
nC.Steve jobs\t\tD.Bill gates");
if(toupper(getch())=='C')
{
printf("\n\nCorrect!!!");
countr++;
getch();
break;
44
}
else
{
printf("\n\nWrong!!! The correct answer is
C.Steve jobs");
getch();
goto score;
break;
}
}
}
score:
system("cls");
score=(float)countr*100000;
if(score>0.00 && score<1000000)
{
printf("\n\n\t\t****************
CONGRATULATION *****************");
printf("\n\t You won $%.2f",score);
goto go;
}
else if(score==1000000.00)
{
printf("\n\n\n \t\t****************
45
CONGRATULATION ****************");
printf("\n\t\t\t\t YOU ARE A
MILLIONAIRE!!!!!!!!!");
printf("\n\t\t\t\t You won $%.2f",score);
printf("\n\t\t\t\t Thank You !!");
}
else
{
printf("\n\n\t******** SORRY YOU DIDN'T WIN
ANY CASH ********");
printf("\n\t\t Thanks for your participation");
printf("\n\t\t TRY AGAIN");
goto go;
}
go:
puts("\n\n Press Y if you want to play next game");
puts(" Press any key if you want to go main menu");
if (toupper(getchar())=='Y')
{
goto home;
}
else
{
edit_score(score,playername);
goto mainhome;
}
}
46
}
void show_record()
{
char name[20];
float scr=0;
FILE *f;
f=fopen("score.txt","r");
fscanf(f,"%s%f",&name,&scr);
printf("\n\n\t\
t******************************************************
*******");
printf("\n\n\t\t %s has secured the Highest Score
%f",name,scr);
printf("\n\n\t\
t******************************************************
*******");
fclose(f);
getch();
}
void reset_score()
{
system("cls");
float sc;
char nm[20];
FILE *f;
f=fopen("score.txt","r+");
47
fscanf(f,"%s%f",&nm,&sc);
sc=0;
fprintf(f,"%s,%.2f",nm,sc);
fclose(f);
}
void help()
{
system("cls");
printf("\n\n HELP");
printf("\n
-------------------------------------------------------------------------");
printf("\n ......................... C program Quiz Game...........");
printf("\n >> There are two rounds in the game, WARMUP
ROUND & CHALLANGE ROUND");
printf("\n >> In warmup round you will be asked a total of 3
questions to test your general");
printf("\n knowledge. You will be eligible to play the game
if you can give atleast 2");
printf("\n right answers otherwise you can't play the
Game...........");
printf("\n >> Your game starts with the CHALLANGE
ROUND. In this round you will be asked");
printf("\n total 10 questions each right answer will be
awarded $100,000.");
printf("\n By this way you can win upto ONE MILLION
cash prize in USD...............");
printf("\n >> You will be given 4 options and you have to
48
press A, B ,C or D for the");
printf("\n right option");
printf("\n >> You will be asked questions continuously if you
keep giving the right answers.");
printf("\n >> No negative marking for wrong answers");
printf("\n\n\t*********************BEST OF
LUCK*********************************");
printf("\n\n\t*****C PROGRAM QUIZ GAME is
developed byDEEPAK SHARMA AP GOYAL SHIMLA
UNIVERSITY********");}
void edit_score(float score, char playernm[20])
{
system("cls");
float sc;
char nm[20];
FILE *f;
f=fopen("score.txt","r");
fscanf(f,"%s%f",&nm,&sc);
if (score>=sc)
{
sc=score;
fclose(f);
f=fopen("score.txt","w");
fprintf(f,"%s\n%.2f",playernm,sc); //print in player
name
fclose(f);
}
49
}
50
OUTPUT 4. RESULTS AND DISCUSSIONS
51
52
53
CONCLUSION AND RECOMMENDATIONS
54
6. IMPLICATIONS FOR FUTURE RESEARCH
55
REFERENCES
[2] www.gobookee.net/objective-type-questions-C++-language/
[3] www.gobookee.net/objective-type-questions-and-answers-in-dbms/
[4] www.gobookee.net/objective-type-questions-and-answers-in-c/
56