Quiz Your self!!!

shouvik 0 Tallied Votes 114 Views Share

Have a look at this programme. it is my semister project

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>
void recta(int r1,int r2,int c1,int c2)
{ gotoxy(r1,c1);
cout<<(char)218;
gotoxy(r2,c2);
cout<<(char)217;
gotoxy(r1,c2);
cout<<(char)192;
gotoxy(r2,c1);
cout<<(char)191;
for( int a=c1+1;a<c2;a++)
{gotoxy(r1,a);
cout<<(char)179;
gotoxy(r2,a);cout<<(char)179;
}
for(a=r1+1;a<r2;a++)
{gotoxy(a,c1);
cout<<(char)196;
gotoxy(a,c2);cout<<(char)196;
} }
void recta1(int r1,int c1)
{int r2=r1+25;
int c2=c1+2;
gotoxy(r1,c1);
cout<<(char)218;
gotoxy(r2,c2);
cout<<(char)217;
gotoxy(r1,c2);
cout<<(char)192;
gotoxy(r2,c1);
cout<<(char)191;
for( int a=c1+1;a<c2;a++)
{gotoxy(r1,a);
cout<<(char)179;
gotoxy(r2,a);cout<<(char)179;
}
for(a=r1+1;a<r2;a++)
{gotoxy(a,c1);
cout<<(char)196;
gotoxy(a,c2);cout<<(char)196;
} }
int que(char q[40],char a[20],char b[20],char c[20],char d[20],int n,int li,int ci)
{int mark=0;
int x;
cout<<"\n\n";
textcolor(WHITE);
cout<<(char)218;
for(int i=0;i<71;i++)
{
cout<<(char)196;
}
cout<<(char)191;cout<<endl;
cout<<(char)179;
cout<<"QUESTION-"<<n;

for( i=0;i<54;i++)
{
cout<<" ";
}
cout<<"LEVEL-"<<ci;
cout<<(char)179;
cout<<endl;
cout<<(char)192;
for(i=0;i<71;i++)
{
cout<<(char)196;
}
cout<<(char)217;
cout<<"\n\n"<<" ";
cout<<q;
cout<<"\n\n";
textcolor(GREEN);
cputs(" (1) ");
textcolor(WHITE);
cputs(a);cout<<endl;
textcolor(GREEN);
cputs(" (2) ");
textcolor(WHITE);
cputs(b);cout<<endl;
textcolor(GREEN);
cputs(" (3) ");
textcolor(WHITE);
cputs(c);cout<<endl;
textcolor(GREEN);
cputs(" (4) ");
textcolor(WHITE);
cputs(d);cout<<endl<<endl;
cout<<"ans:";
cin>>x;
if(x==li)
{mark+=1;
cout<<endl;
cputs("CORRECT");
}
else
{cout<<endl;
cputs("INCORRECT");
}
return mark;
}
int que1(char q[40],char a[20],char b[20],char c[20],char d[20],int n,int li,int ci)
{int mark=0;
int x;
cout<<"\n\n";
textcolor(WHITE);
cout<<(char)218;
for(int i=0;i<71;i++)
{
cout<<(char)196;
}
cout<<(char)191;cout<<endl;
cout<<(char)179;
cout<<"QUESTION-"<<n;

for( i=0;i<53;i++)
{
cout<<" ";
}
cout<<"LEVEL-"<<ci;
cout<<(char)179;
cout<<endl;
cout<<(char)192;
for(i=0;i<71;i++)
{
cout<<(char)196;
}
cout<<(char)217;
cout<<"\n\n"<<" ";
cout<<q;
cout<<"\n\n";
textcolor(GREEN);
cputs(" (1) ");
textcolor(WHITE);
cputs(a);cout<<endl;
textcolor(GREEN);
cputs(" (2) ");
textcolor(WHITE);
cputs(b);cout<<endl;
textcolor(GREEN);
cputs(" (3) ");
textcolor(WHITE);
cputs(c);cout<<endl;
textcolor(GREEN);
cputs(" (4) ");
textcolor(WHITE);
cputs(d);cout<<endl<<endl;
cout<<"ans:";
cin>>x;
if(x==li)
{mark+=1;
cout<<endl;
cputs("CORRECT");
}
else
{cout<<endl;
cputs("INCORRECT");
}
return mark;
}
void disp1(char a[100],int x,int y)
{
int f=strlen(a);
gotoxy(x,y);
for(int i=0;i<f;i++)
{delay(10);
cout<<a[i];
}
}


int level1()
{int m=0;
textbackground(BLUE);
textcolor(WHITE);
clrscr();
m+=que("Who proposed the theory of mutation?","Mendeleev","Pascal","Louis Pasteur","Mendel",1,4,1);
m+=que("Who invented the first antibiotic","Hooks","Alexander Fleming","Shildon","Rudolph Virchow",2,2,1);
m+=que("Which is the longest strait?","Malaka Strait","Palk Strait","Gibraltar","Suez strait",3,1,1);
m+=que("Which is the largest lake in the world","Titikaka","Chilka","Baikal","Caspian sea",4,4,1);
m+=que("Where do tribals called Zulus reside?","Nigeria","South Africa","Venezuela","Egypt",5,2,1);
m+=que("Who led the great bolshevik revolution?","Stalin","Karl Marx","The Czar","Lenin",6,4,1);
m+=que("When was the Bohr War fought?","1970","1880","1899","1400",7,3,1);
m+=que("Who is known as the father of Radioactive physics?","E Fermi","H Becquerel","Heisenberg","Rutherford",8,2,1);
m+=que("On whose theory is the modern periodic table based?","Moseley","Mendeleev","Heisenberg","Rutherford",9,1,1);
m+=que1("Who invented vulcanized rubber?","Dunlop","J Vulcan","C Goodyear","Diamler",10,3,1);
return m;
}
int level2()
{int m=0;
textbackground(BLUE);
textcolor(WHITE);
clrscr();
m+=que("Who proposed the theory of relativity?","Newton","Pascal","Louis Pasteur","Einstien",1,4,2);
m+=que("How many bones are there in the human body?","120","206","403","221",2,2,2);
m+=que("Which battle marked the downfall of Napoleon?","Battle of Waterloo","World war 1","Bohr War","American Civil War",3,1,2);
m+=que("Which city is known as the city of joy?","Calcutta","Chicago","Berlin","Paris",4,1,2);
m+=que("What is the new name of South Rhodesia","Nigeria","Zimbabwe","Venezuela","Egypt",5,2,2);
m+=que("Which is the national game of USA?","Football","Baseball","Basketball","Hockey",6,2,2);
m+=que("Sunny days is the autobiography of?","Ian Botham","Viv Richards","Kapil Dev","Sunil Gavaskar",7,4,2);
m+=que("Who is the author of Mein Kempf?","Adolf Hitler","Winston Churchill","Roosevelt","M L King",8,1,2);
m+=que("Where is the famous Bermuda Triangle located?","Black Sea","Mediterranaen Sea","Caspian Sea","Atlantic Ocean",9,4,2);
m+=que1("Who is the father of white revolution in India ?","M L Singh","V Kurien ","C V Raman","H J Bhabha",10,2,2);
return m;
}

int level3()
{int m=0;
textbackground(BLUE);
textcolor(WHITE);
clrscr();
m+=que("Who was the first thirthankar of jainism?","Mahavira","Uddalaka","Rishabhadeva","aghnideva",1,1,3);
m+=que("how many nuclear tests has US conducted?","<100","<500",">1000",">4000",2,3,3);
m+=que("What is the currency of Bangladesh?","rupee","ruphiah","taka","peseta",3,3,3);
m+=que("When was People's Republic of China established","1934","1949","1989","1900",4,2,3);
m+=que("Who introduced the terms glasnost and pretroiko ","George Bush","Gorbache","Yeltsin","Stalin",5,2,3);
m+=que("Who invented the polio vaccine","J E Salk","Pasteur","E Jenner","Pascal",6,1,3);
m+=que("As bad as i wanna be is the autobiography of?","Ian Botham","Micheal Jordan","Dennis Rodman","Maradona",7,3,3);
m+=que("Who is the author of 'the god of small things'?","Sydney Sheldon","Arundhati Roy","Ken Follett","R L Stine",8,1,3);
m+=que("Where is the famous Barrier Reef located?","England","India","USA","Australia",9,4,3);
m+=que1("?Name the grasslands of Europe","Steppes","Downs ","Praires","Pampas",10,1,3);
return m;
}
void disp(char a[100],int x,int y)
{clrscr();
gotoxy(x,y);
int e=strlen(a);
for(int i=0;i<e;i++)
{
delay(125);
cout<<a[i];
}
}
void start()
{
textmode(C40);
textcolor(WHITE);
textbackground(BLUE);
delay(2000);
disp("SAS PROGRAMMERS GROUP PRESENTS",6,12);
delay(1000);
char head[20]="BRAINRACKER";
disp(head,15,12);
delay(1000);
disp("THE ULTIMATE QUIZ CHALLENGE",8,12);
delay(1500);
}
int start1()
{
textmode(C80);
textbackground(BLUE);
textcolor(YELLOW);
clrscr();
recta(20,60,6,21);
delay(1000);
gotoxy(31,8);
cputs("BRAINRACKER-MAIN MENU");
delay(250);
textcolor(CYAN);
gotoxy(31,10);
cputs("1.START QUIZ");
delay(250);
gotoxy(31,12);
cputs("2.ABOUT THIS PR0GRAM");
delay(250);
gotoxy(31,14);
cputs("3.CREDITS");
delay(250);
gotoxy(31,16);
cputs("4.INSTRUCTIONS");
delay(200);
gotoxy(31,18);
cputs("5.EXIT");
gotoxy(31,23);
cputs("ENTER YOUR CHOICE:");
int y;
cin>>y;
return y;
}
void sorry()
{textmode(C40);
textcolor(RED);
clrscr();
delay(1500);
disp1("YOU COULD NOT ADVANCE TO THE NEXT LEVEL",1,12);
delay(3000);
}

int level4()
{int m=0;
textbackground(BLUE);
textcolor(WHITE);
clrscr();
m+=que("When did USA become independent?","1788","1776","1789","1800",1,2,4);
m+=que("Which is the highest waterfall in the world?","Niagara Falls","Angel Falls","Fischer falls","St.Louis falls",2,2,4);
m+=que("What is the currency of Italy?","Italian Dollar","Denarii","Lira","Rouble",3,3,4);
m+=que("Where were the first Asian Games held?","Bangkok","New Delhi","Beijing","Singapore",4,2,4);
m+=que("When were the first Modern Olympics held?","1896","1806","1490","1895",5,1,4);
m+=que("Which of the following scientists was a Jew?","Heisenberg","Rutherford","Madam Curie","Einstien",6,4,4);
m+=que("Which is the largest temple of the world","Konark temple","Omkar temple","Ankor Watt","Sun temple",7,3,4);
m+=que("Which of the following is known as the city oflakes?","Geneva","Bangkok","Venice","Paris",8,3,4);
m+=que("Which country has more than 55000 lakes?","USA","Finland","Sweden","France",9,2,4);
m+=que1("Which philosopher drank the cup of hemlock","Socrates","Plato","Kurt Godel","Karl Marx",10,1,4);
return m;
}
int sport1()
{int m=0;
m+=que("Who is the hoghest run getter in ONI's ?","Allan Border","Desmond Haynes","Brain Lara","Mohd.Ahzaruddin",1,4,5);
m+=que("Who won the ladies Wimbledon Tennis Title 9 times ?","Martina Navratilova","Chris Evert","Steffi Graf","Martina Hingis",2,1,5);
m+=que("Who has the maximum no of career pts in the NBA ?","Micheal Jordan","Dennis Rodman","Abdul Jabbar","Karl Malone",3,3,5);
m+=que("Which boxer was infamous for repeatedly saying'Iam the greatest'?","Mike Tyson","Mohd.Ali","E Holyfield","Lyon King",4,2,5);
m+=que("When did India win the cricket World Cup?","1993","1983","1979","1975",5,1,5);
m+=que("Who has the highest international test batting average till date ?","Micheal Bevan","Allan Border","D Bradman","Desmond Haynes",6,3,5);
m+=que("Which is the largest temple of the world","Konark temple","Omkar temple","Ankor Watt","Sun temple",7,4,5);
m+=que("Which of the following is known as the city oflakes?","Geneva","Bangkok","Venice","Paris",8,3,5);
m+=que("Which country has more than 55000 lakes?","USA","Finland","Sweden","France",9,2,5);
m+=que1("Which philosopher drank the cup of hemlock","Socrates","Plato","Kurt Godel","Karl Marx",10,1,5);
return m;
}
int level5()
{
textbackground(BLUE);
textcolor(WHITE);
clrscr();
int m=0;
m+=que("Which canal connects the North Sea and the Baltic Sea?","Suez Canal","Keil Canal","Thompson Canal","St. Edward Canal",1,2,5);
m+=que("Who first used acupuncture?","Romans","Indians","Chinese","Japanese",2,3,5);
m+=que("When was the television invented?","1892","1941","1966","1926",3,4,5);
m+=que("Which city is known as the Pink City?","Calcutta","Chicago","Jaipur","Moswcow",4,3,5);
m+=que("What is the new name of Belgian Congo","Nigeria","Zaire","Malaysia","Madagascar",5,2,5);
m+=que("How many cells are there in a newborn baby?","90 Billion","3 Million","26 Billion","76 Million",6,3,5);
m+=que("Which is the only car in the UK without a numberplate?","PM's Car","Vice Chancellor's car","King's Car","Queen's Car",7,4,5);
m+=que("What is the age of the Sun?","5 Billion Years","10 Billion Years","3 Billion Years","16 Billion Years",8,1,5);
m+=que("How many moons does Jupiter have?","10","32","5","17",9,4,5);
m+=que1("Which of the following Rivers flow into the Black Sea?","Thames","Rhine ","Danube","Volga",10,3,5);
return m;
}

void fscore(int r,int r1,int r2,int r3,int r4,int tot)
{textmode(C80);
textcolor(RED);
textbackground(BLACK);
clrscr();

disp1("SCORE SUMMARY",35,3);

recta(25,55,5,17);
recta(40,55,5,17);
recta(22,60,19,23);
disp1("REMARKS",36,18);
gotoxy(30,6);
cout<<"LEVEL";
gotoxy(45,6);
cout<<"SCORE";
textbackground(BLACK);
textcolor(GREEN);

if((r>5)&&(r1>5)&&(r2>5)&&(r3>5))
{disp1("level 1:",28,8);
gotoxy(48,8);
cout<<r;
disp1("level 2:",28,10);
gotoxy(48,10);
cout<<r1;
disp1("Level 3:",28,12);
gotoxy(48,12);
cout<<r2;
disp1("level 4:",28,14);
gotoxy(48,14);
cout<<r3;
disp1("Level 5:",28,16);
gotoxy(48,16);
cout<<r4;
disp1("performance:excellent",26,22);
disp1("you reached the final level",26,20);
}
else if((r>5)&&(r1>5)&&(r2>5))
{disp1("level 1:",28,8);
gotoxy(48,8);
cout<<r;
disp1("level 2:",28,10);
gotoxy(48,10);
cout<<r1;
disp1("level 3:",28,12);
gotoxy(48,12);
cout<<r2;
disp1("level 4:",28,14);
gotoxy(48,14);
cout<<r3;
disp1("performance:very good",26,22);
disp1("you reached level 4",26,20);
}
else if((r>5)&&(r1>5))
{ disp1("level 1:",28,8);
gotoxy(48,8);
cout<<r;
disp1("level 2:",28,10);
gotoxy(48,10);
cout<<r1;
disp1("level 3:",28,12);
gotoxy(48,12);
cout<<r2;
disp1("performance:good",26,22);
disp1("you reached level 3",26,20);
}
else if(r>5)
{ disp1("level 1:",28,8);
gotoxy(48,8);
cout<<r;
disp1("level 2:",28,10);
gotoxy(48,10);
cout<<r1;
disp1("performance:above average",26,22);
disp1("you reached level 2",26,20);
}
else
{disp1("level 1:",28,8);
gotoxy(48,8);
cout<<r;
disp1("performance:average",26,22);
disp1("you did not advance beyond level 1",26,20);
}
cout<<endl;
disp1("total score:",26,21);
cout<<tot;
disp1(">>press any key to return to menu...........",25,25);
getch();
}
void pscore(int r)
{ if(r==10)
{textmode(C40);
textcolor(BLUE);
delay(1000);
disp("PERFECT SCORE",14,12);
delay(3000);
}
}
void stat(int r,int p)
{
textmode(C80);
textbackground(BLACK);
textcolor(GREEN);
clrscr();
recta(25,55,7,13);
disp1("LEVEL STATISTICS",32,3);
disp1("YOUR LEVEL SCORE:",30,9);
cout<<r;
disp1("PERCENTAGE",30,11);
cout<<" "<<p<<"%";
disp1(">>press any key to proceed.........",25,16);
getch();
}
void submain()
{clrscr();
int x=start1();
char w[60]="Brainracker is an interactive multilevel Quiz programme";
char t[60]="which tests your knowledge in all spheres.It contists of";
char g[60]="more than 50 questions in different categories or topics.";
char l[60]="It includes a multilevel general quiz for an overall ";
char m[60]="test of your knowledge.This has five levels of increasing";
char n[60]="difficulty.The player has to answer at least 5 questions ";
char j[60]="out of ten to advance to the next level.";
char t1[70]="In order to play the Quiz select start quiz from the ";
char e[60]="main menu and answer each multiple choice question by ";
char v[60]="typing the no of your answer.The program examines whether ";
char i[60]="you have answered correctly and shows the relevant message.";
char d[60]="This continues and succesive levels appear till you ";
char x1[60]="complete all levels or fail to score at least 5 in one ";
char q[60]="level.After this score for each level is displayed.";
switch(x)
{
case 1: { recta1(27,9);
delay(2500);
clrscr();int r=0,r1=0,r2=0,r3=0,r4=0;
textmode(C40);
textbackground(BLACK);
textcolor(GREEN);
delay(2000);
disp("LEVEL 1",18,12);
delay(2500);
textmode(C80);
textcolor(WHITE);
r=level1();
int p=(r*10);
int tot=0;
tot+=r;
pscore(r);
delay(500);
stat(r,p);
if (r>5)
{
textmode(C40);
textbackground(BLACK);
textcolor(GREEN);
clrscr();
delay(2000);
disp1("YOU HAVE ADVANCED TO LEVEL 2",7,10);
delay(2000);
clrscr();
disp("LEVEL 2",18,12);
delay(2500);
textmode(C80);
textcolor(WHITE);
clrscr();
r1=level2();
int p1=(r1*10);
clrscr();
pscore(r1);
delay(500);
stat(r1,p1);
tot+=r1;
}

if(r1>5)
{
clrscr();
textmode(C40);
textcolor(GREEN);
textbackground(BLACK);
clrscr();
delay(2000);
disp1("YOU HAVE ADVANCED TO LEVEL 3",7,10);
delay(2500);
clrscr();
disp("LEVEL 3",18,12);
delay(2500);
textmode(C80);
textcolor(WHITE);
clrscr();
r2=level3();
int p2=(r2*10);
pscore(r2);
delay(500);
stat(r2,p2);
tot+=r2;
}

if(r2>5)
{
textmode(C40);
textcolor(GREEN);
textbackground(BLACK);
clrscr();
delay(2500);
disp1("YOU HAVE ADVANCED TO LEVEL 4",7,10);
delay(2500);
clrscr();
disp("LEVEL 4",18,12);
delay(2500);
textmode(C80);
textcolor(WHITE);
clrscr();
r3=level4();
pscore(r3);
int p3=(r3*10);
tot+=r3;
delay(500);
stat(r3,p3);
}

if(r3>5)
{
textmode(C40);
textcolor(GREEN);
textbackground(BLACK);
clrscr();
delay(2000);
disp1("YOU HAVE ADVANCED TO LEVEL 5",7,10);
delay(2500);
disp("LEVEL 5",18,12);
delay(2500);
textmode(C80);
clrscr();
r4=level5();
pscore(r4);
int p4=(r4*10);
tot+=r4;
delay(500);
stat(r4,p4);
}

fscore(r,r1,r2,r3,r4,tot);
submain();
}break;
case 2: {recta1(27,11);
textcolor(RED);
delay(2000);
textmode(C80);
textcolor(GREEN);
clrscr();
delay(2000);
recta(10,71,4,15);
disp1("ABOUT THIS PROGRAM",32,3);
delay(300);
disp1(w,12,6);
delay(100);
disp1(t,12,7);
delay(100);
disp1(g,12,8);
delay(100);
disp1(l,12,9);
delay(100);
disp1(m,12,10);
delay(100);
disp1(n,12,11);
delay(100);
disp1(j,12,12);
disp1(">>press any key to return to menu.........",15,20);
getch();
submain();
}break;
case 3:{recta1(27,13);
textmode(C80);
textcolor(GREEN);
delay(1500);
clrscr();
disp1("CREDITS",35,3);
disp1("This program has been made by SHOUVIK.",12,6);
disp1(">>press any key to return to menu.........",15,20);
getch();
submain();
}break;
case 4:{ recta1(27,15);
textmode(C80);
textcolor(GREEN);
clrscr();
recta(10,72,4,15);
disp1("INSTRUCTIONS",35,2);
disp1(t1,13,6);
disp1(e,13,7);
disp1(v,13,8);
disp1(i,13,9);
disp1(d,13,10);
disp1(x1,13,11);
disp1(q,13,12);
disp1(">>press any key to return to menu.........",15,20);
getch();
submain();
}
case 5:{recta1(27,17);
delay(1500);
textbackground(BLACK);
textcolor(GREEN);
clrscr();
disp1(">>quitting brainracker..........",2,2);

delay(700);
disp1(">>press enter..........",2,3);

}
break;
default:{textbackground(BLACK);
textcolor(GREEN);
clrscr();
disp1(">>invalid choice entered...",1,1); delay(700);
disp1(">>returning to menu....",1,2);delay(1500);
submain();
}
}

getch();
}
void main()
{start();
submain();
}
mikeandike22 18 Nearly a Posting Virtuoso

When i compiled it i got 68 errors.

shouvik 0 Newbie Poster

Well I suppose u try correccting them then. they are working fine oon my compiler...

thakur ravi 0 Unverified User

yes

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.