You are on page 1of 25

INDEX

INTRODUCTION TO C++

INTRODUCTION TO PROJECT

HEADER –FILES AND
FUNCTIONS USED

SOURCE CODE

FUTURE VALIDATIONS

OUTPUT

INTRODUCTION TO 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, high performance
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:

• 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.

• C++ 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.

• C++ 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 increases the knowledge of the player. The player needs to type either A. In this program several question are provided to the player.Windows XP or above Keyboard Turbo C++ . or D according to the suitable answer provided in it. This program is based on the exploitation of the ordered arrangement of question number. This program displays questions in a random order from the question bank. C. INTRODUCTION TO PROJECT Quiz game is a very popular General Knowledge Game. It is used to check the knowledge within us. The player will score the points with each correct answer provided marks will be deducted for wrong answer. SYSTEM REQUIREMENTS Operating System. options and the answer in a file. The provided source code is a simple Quiz game programmed in C++ language. The highlight of this program is that question bank can be updated (users can add questions to the question bank). Player is all need to choose the suitable option from the 4 option available in the screen. The players are provided with 4 options in it. question. B.

h Provides function for file handilng 6 process.int To conduct the quiz ar[10]) 4 void define() To pass question numbers to func() by invoking rndm() 5 void display() To display the points scored 6 void edit() To add questions .No Functions Description 1 void rndm(int ar[10]) To generate random question numbers 2 void init() To get details from user 3 void func(int q.h Used for strcmp() 4 stdio. HEADER FILES AND FUNCTIONS USED S No.h Used for getch() and clrscr() 3 string.h Used for generating random numbers 8 ctype.h Provides functions for standard I/O operations 2 conio.h Used for gets() 5 fstream. Header files Description 1 iostram.h Provides functions for character handling S.h Used for exit(0) 7 stdlib.

float x. void define().s[100].int ar[10]). SOURCE CODE #include<iostream.} void rndm(int ar[10]). void questions(). public: contest() {x=0.h> #include<fstream.0. void func(int q.h> #include<conio.h> #include<stdio.h> #include<ctype. .h> #include<string.h> #include<stdlib.ans[100]. char name[20].h> #include<process.h> class contest {int roll. void init().

4. { { {while(i<11) { cout<<i<<")".2. questions(). void edit().open("ques.12. }.r. } } } . i++.7.11. void contest::define() {int arr[]={1.10.13}.txt"). rndm(arr).6. ifstream in.9.5.void display(). int i=1. func(i-1.8. char A. in.arr).3.sh.} return.

answer.open("ques. cout<<endl<<s<<endl.} void contest::func(int p. {if(sh==array[p]) { { do { fin. int i=0.} while(r<(sh-1)*5+2). { if(j%5==3) . if(i%5==1) in>>sh. while(!fin.100).sh. fin.txt").txt"). in.open("ques. char A.fin.r++.getline(s.r=0.eof()) { i++.int array[]) { ifstream in.j=1.

} else { if(x>0) x=x-2. } else if(answer==A) { x=x+5. .5.{ fin. cout<<"wrong answer\n".get(A). j=-1. if(answer<'a'||answer>'d') {cout<<"wrong choice". i=-1. cout<<"your answer is correct\n". gets(ans). goto lb. answer=tolower(ans[0]). lb: cout<<"\nans: ". cout<<"the correct answer is "<<A<<endl.

} cout<<"press any key to continue". --i) { . return. clrscr().close(). } j++. //shuffle p for (int i=12. i>0. } in. } void contest::rndm(int p[]) {randomize(). cout<<endl<<endl. } } } } if(i%5==1)sh++. getch().

. file<<" c. //copy first n elements from p to arr for ( i=0. //swap p[i] with p[j] int temp = p[i]. p[j] = temp. } int ar[10].1823\n". } void contest::questions() {ofstream file. file<<" c. //get swap index int j=random(i). p[i] = p[j].1834 \t d. file<<"2\n Which day is celebrated as 'World Computer Literacy day'?\n".December 2\n".txt").1820 \t b. i<10. file. ++i) ar[i] = p[i].May 15\n". file<<'b'<<"\n".open("ques.1922\n".October 6 \t b. file<<" a. file<<'a'<<"\n". file<<"1\n When computer was first invented?\n".October 4 \t d. file<<" a.

Portable Document Format \t b.file<<"3\n Who is known as human computer of India?\n". file<<" a. Shakunthala Devi\t c. file<<" c. Sundar Pichai \t b. file<<"4\n 'Do no evil' is the tag line of\n". file<<'c'<<"\n". Microsoft \t b.Derek o brein\n". Personal Document Format\n". file<<" a. file<<"8\n Technology no longer protected by copyrights and available to all is \n". file<<" a. file<<" c. Silicon\n". file<<'b'<<endl. Lead \t b. Apple\n". file<<" c. file<<" c. Google\n". file<<'d'<<"\n". file<<"5\n Extension of PDF\n". file<<'a'<<"\n". Gold\n". Linux \t d. file<<" a. Adobe \t b. Microsoft\n". file<<" c. Portable Digital format \t d. file<<'a'<<endl. Open\n".IBM\n". .Sathya Nathella\n". file<<"6\n Which company invented floppy disk?\n". Proprietary \t b. file<<"7\n IC chips are usually made of\n". file<<" a. Intel \t d. Chromium \t d. Presentation Document Format\n". file<<" a.

100Mbit/s \t b. file<<"11\n Who invented graphical use interface(GUI)?\n".1 Gbit/s \t c.Binary number\n". file<<'a'<<endl. Free\n". file<<" c.480 Mbit/s\n". file<<" a. file<<" c.Samsung\n". file<<" a. AMD\n". 250 Mbit/c\n". file<<" a.file<<" c. . file<<"9\n In binary language each alphabet is made up of unique combination of \n". file<<'d'<<endl.Xerox \t d. Experimental \t d.0?\n". HP \t b. IBM\n". file<<"13\n Who invented USB?\n".8 kbytes\n". Binary language\n". 8 bytes \t b. file<<'c'<<endl .Apple\n". 8 character \t d. file<<'c'<<endl. file<<"12\n What is the transfer rate of a satandard USB2. file<<'b'<<endl. file<<" c. 8 bits\n". file<<" c. file<<" c. Binary digit \t d. file<<"10\n The term bit is short for\n".Microsoft \t b. file<<" a. Intel \t d. file<<'c'<<endl. Byte \t b. file<<" a.

"admin")==0) { ofstream out. out<<q<<"\n". out<<"a. cout<<"enter password \t".c[100].q[100].b[100]. gets(password). if(strcmp(password.close(). cin>>no. gets(a). cout<<"Enter option a\n". cout<<"enter options\n". out<<no+13<<endl. "<<a<<"\t".txt".answer. . out. gets(q).open("ques. } void contest::edit() { char password[25]. cout<<"Enter option b\n". cout<<"Enter question name\n".a[100].d[100].file.ios::app). cout<<"Enter question no\n". int no.

". "<<b<<"\n". cin>>roll. out<<"c. gets(c). out. "<<d<<"\n". out<<answer<<"\n".".close(). } void contest::display() { . out<<"d. } } void contest::init() { cout<<"contestant name .gets(b). cin>>answer. gets(d). cout<<"Enter option c\n". out<<"b. gets(name). "<<c<<"\t". cout<<"contestant roll no . cout<<"Enter option d\n". cout<<"enter correct option\n".

cout<<"\n\t FIRST OPTION to be entered will be considered\n".init().\n". int c. cout<<"Press any key to continue". clrscr(). getch(). r. cout<<" \n\n\n\t\t\t Quiz Contest\n". cout<<"\nresult:: \n"<<name<<" got total "<<x<<" marks \n". . contest r. cout<<"5 points will be awarded for each correct answer and\n".\n". cout<<"\t0 quit\n". cout<<"\t2. } void main() { clrscr().5 marks will be DEDUCTED for each wrong answer.". cout<<"If more than one options are entered. L: cout<<"\nSelect your choice \n\t1 start\n\t2 display\n\t3 add questions\n". cout<<endl<<endl. cout<<"This is a multiple choice quiz contest. cout<<"GENERAL INSTRUCTIONS\n".

display(). case 2: r. default: cout<<"wrong choice \n".define(). break. break.edit(). cin>>reply. } . switch(c) {case 1: r. } cout<<"\nenter your reply : Press y for continuing \t". case 0: goto Last. if(reply=='y'||reply=='Y') goto L. else Last: cout<<"\n\n\nTHANKS FOR SPENDING YOUR VALUABLE TIME". clrscr().cin>>c. break. case 3: r. char reply. cout<<"\nDone by Pugazhendhi and Shivakumar". getch().

FUTURE VALIDATIONS 1) Inclusion of timer 2) Inclusion of graphics 3) Producing sound Output for a sample run .