Saturday, 5 April 2014

A Quiz Program

Well this program is quite long but u all will be satisfied after using it.It is a program for a quiz which u all can also change according to u. Enjoy the game.

#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<stdio.h>
#include<dos.h>
struct Question
{
  char Q1[50],Q2[50],Q3[50],Q4[50],Q5[50],Q6[50],Q7[50],Q8[50],Q9[50],Q10[50];
};
struct Answer
{
  int A1,A2,A3,A4,A5,A6,A7,A8,A9,A10;
};
void main()
{
   Question q={"What is the capital of Italy ?",
                         "Title given to Rabindranath Tagore by Britishers ",
                         "Who is known as the 'Iron Lady ' of India ?",
                         "Manufacturer of the Fibrous Alumina",
                         "Location of the 2022 FIFA World Cup ",
                         "Who is Japan's No.1 tennis player ?",
                  "'Sugar Bowl' of the world is ",
                  "Highest Waterfall of India ",
                  "Headquaters of UNESCO ",
                  "Winner of FIFA Ballon d'Or 2013 is "
                         };
  Answer a={1,4,2,3,1,3,2,4,3,1};
  int b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,age,i=0;
  int ca=0,wa=0;
  long money=1000;
  char name[25],sex,place[50];
  clrscr();
  textbackground(RED);
  textcolor(YELLOW);
  clrscr();
  textbackground(RED);
  textcolor(YELLOW);
  cout<<"\n\n";
  for(i=0;i<27;i++)
  {
    cout<<".";
    delay(100);
  }
  cout<<"WELCOME TO THE QUIZ CORNER";
  for(i=0;i<27;i++)
  {
    cout<<".";
    delay(100);
  }
  cout<<"\n\n\nFirst tell about yourself...\n\n";
  textcolor(GREEN);
  cout<<"Name :\t\t ";
  gets(name);
  cout<<"\n\nAge :\t\t ";
  cin>>age;
  cout<<"\n\nSex(M/F) :\t ";
  cin>>sex;
  cout<<"\n\nPlace(State) :\t ";
  gets(place);
  getch();
  clrscr();
  textbackground(BLACK);
  textcolor(YELLOW);
  clrscr();
  
  for(i=0;i<17;i++)
   {
     cout<<"*.";
     delay(100);
   }
   cout<<"INSTRUCTIONS";
   for(i=0;i<17;i++)
     {
       cout<<".*";
       delay(100);
     }
   textcolor(GREEN);
   cout<<"\n\n1.There are 10 questions in the quiz game.";
   cout<<"\n2.Each correct answer doubles your money.";
   cout<<"\n3.When you give a wrong answer, you lose.";
   cout<<"\n4.Answers shoul be given in digits only.";
   cout<<"\n5.You will start with a total of Rs.1000,which is minimum amount to be won.";
   cout<<"\n6.Don't try to cheat.This is just a game...";
   cout<<"\n\n\n\t\t\t  ****** Let us Begin ******";
   cout<<"\nPress any key to continue...";
   getch();
   clrscr();
   textbackground(RED);
   textcolor(BLUE);
   clrscr();
   textbackground(RED);
   textcolor(BLUE);
   cout<<"\n\nQuestion 1: "<<q.Q1;
   cout<<"\n\n\t\t1.Rome\t\t\t2.Paris\n\t\t3.Ohio\t\t\t4.Tokyo\n\n";
   cout<<"Enter your choice...";
   cin>>b1;
   if(b1==a.A1)
    {
       cout<<"Your answer is ";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
       }
              cout<<"Correct";
                 ca++;
              money=money*2;
     }
   else
     {
             sound(500);
       delay(600);
       nosound();
             cout<<"Your answer is";
             for(i=0;i<25;i++)
              {
                cout<<".";
                delay(100);
              }
                cout<<"Wrong";
                cout<<"\n\nCorrect answer is "<<a.A1;
                 wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is Rs."<<money;
    getch();
    clrscr();
  textcolor(GREEN);
  cout<<"\n\nQuestion 2: "<<q.Q2;
  cout<<"\n\n\t\t1.Prince\t\t\t 2.Knight\n\t\t3.Duke\t\t\t\t 4.Sir\n\n";
  cout<<"Enter your choice...";
  cin>>b2;
  if(b2==a.A2)
    {
       cout<<"Your answer is ";
       for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is ";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A2;
       wa++;
       cout<<"\nYou lose.... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is Rs."<<money;
    getch();
  clrscr();
  textcolor(CYAN);
  cout<<"\n\nQuestion 3: "<<q.Q3;
  cout<<"\n\n\t\t1.Pratiba Patil\t\t\t        2.Indira Gandhi\n\t\t3.Vasundhara Raje\t\t\t4.Sarojini Naidu\n\n";
  cout<<"Enter your choice...";
  cin>>b3;
  if(b3==a.A3)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A3;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is Rs."<<money;
    getch();
  clrscr();
  textcolor(BROWN);
  cout<<"\n\nQuestion 4: "<<q.Q4;
  cout<<"\n\n\t\t1.FCB\t\t\t2.PCB\n\t\t3.Du Pont\t\t4.RSS\n\n";
  cout<<"Enter your choice...";
  cin>>b4;
  if(b4==a.A4)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    { 
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A4;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is Rs."<<money;
    getch();
  clrscr();
  textcolor(YELLOW);
  cout<<"\n\nQuestion 5: "<<q.Q5;
  cout<<"\n\n\t\t1.Qatar\t\t\t\t2.Paris\n\t\t3.Moscow\t\t\t4.Brazil\n\n";
  cout<<"Enter your choice...";
  cin>>b5;
  if(b5==a.A5)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is wrong";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A5;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is Rs."<<money;
    getch();
  clrscr();
  textcolor(GREEN);
  cout<<"\n\nQuestion 6: "<<q.Q6;
  cout<<"\n\n\t\t1.Roger Federrer\t\t2.Rafael Nadal\n\t\t3.Kei Nishikori\t\t\t4.Thomas Berdich\n\n";
  cout<<"Enter your choice...";
  cin>>b6;
  if(b6==a.A6)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is wrong";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A6;
       wa++;
       cout<<"You lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is "<<money;
  getch();
  clrscr();
  textcolor(CYAN);
  cout<<"\n\nQuestion 7: "<<q.Q7;
  cout<<"\n\n\t\t1.Ghana\t\t\t\t2.Cuba\n\t\t3.Sri Lanka\t\t\t4.Japan\n\n";
  cout<<"Enter your choice...";
  cin>>b7;
  if(b7==a.A7)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A7;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is "<<money;

    getch();
    clrscr();
    textcolor(BROWN);
  cout<<"\n\nQuestion 8: "<<q.Q8;
  cout<<"\n\n\t\t1.Dhuadhar Falls\t\t2.Elephanta Falls\n\t\t3.Dudhsagar Falls\t\t4.Jog Falls\n\n";
  cout<<"Enter your choice...";
  cin>>b8;
  if(b8==a.A8)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A8;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is "<<money;

    getch();
    clrscr();
    textcolor(BLUE);
  cout<<"\n\nQuestion 9: "<<q.Q9;
  cout<<"\n\n\t\t1.California\t\t\t2.New York\n\t\t3.Paris\t\t\t\t4.Geneva\n\n";
  cout<<"Enter your choice...";
  cin>>b9;
  if(b9==a.A9)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is ";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A9;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is "<<money;

    getch();
    clrscr();
textcolor(GREEN);
  cout<<"\n\nQuestion 10: "<<q.Q10;
  cout<<"\n\n\t1.Chritiano Ronaldo\t\t2.Franck Lampard\n\t3.Lionel Messi\t\t\t4.Luis Suarez\n\n";
  cout<<"Enter your choice...";
  cin>>b10;
  if(b10==a.A10)
    {
       cout<<"Your answer is ";
for(i=0;i<25;i++)
   {
     cout<<".";
     delay(100);
   }
   cout<<"Correct";
       ca++;
       money=money*2;
    }
  else
    {
       sound(500);
       delay(600);
       nosound();
       cout<<"Your answer is";
       for(i=0;i<25;i++)
       {
              cout<<".";
              delay(100);
            }
            cout<<"Wrong";
       cout<<"\n\nCorrect answer is "<<a.A10;
       wa++;
       cout<<"\nYou lose..... ";
       cout<<"\n\nYour total amount is... Rs."<<money;
       getch();
       exit(0);
    }
    cout<<"\nYour amount is "<<money;

    getch();
    clrscr();
    textbackground(CYAN);
    textcolor(RED);
    clrscr();
    textbackground(CYAN);
    textcolor(RED);
    cout<<"\n\n\n";
    for(i=0;i<38;i++)
    {
       cout<<"*";
       delay(100);
    }
     cout<<"GAME OVER";
    for(i=0;i<33;i++)
    {
       cout<<"*";
       delay(100);
    }
    textcolor(BLUE+BLINK);

    cout<<"\n\nTotal correct answers : "<<ca;
    cout<<"\n\nTotal Wrong answers : "<<wa;
    cout<<"\n\nTotal amount : Rs."<<money;
    textcolor(BROWN+BLINK);
    cout<<"\n\n\n";
    for(i=0;i<38;i++)
    {
       cout<<"*";
       delay(100);
    }
     cout<<"THANK YOU";
    for(i=0;i<33;i++)
    {
       cout<<"*";
       delay(100);
    }

    cout<<"\n\nHOPE YOU LIKED OUR PROGRAM.WE SEE FORWORD TO YOUR APPRECIATON..";
    getch();
    }

No comments: