Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  quiz3
Language: C/C++
Code:
#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:
     system("cls");
     printf("tttC MEELO EVARU ADHRUSTAVANTUDUn");
     printf("ntt________________________________________");

     printf("nttt   WELCOME ");
     printf("nttt      to ");
     printf("nttt   THE GAME ");
     printf("ntt________________________________________");
     printf("ntt________________________________________");
     printf("ntt   BECOME A MILLIONAIRE!!!!!!!!!!!    ") ;
     printf("ntt________________________________________");
     printf("ntt________________________________________");
     printf("ntt > Press S to start the game");
     printf("ntt > Press V to view the highest score  ");
     printf("ntt > Press R to reset score");
     printf("ntt > press H for help            ");
     printf("ntt > press Q to quit             ");
     printf("ntt________________________________________nn");
     choice=toupper(getch());
     if (choice=='V')
     {
     show_record();
     goto mainhome;
     }
     else if (choice=='H')
     {
     help();getch();
     goto mainhome;
     }
     else if (choice=='R')
     {reset_score();
     getch();
     goto mainhome;}
     else if (choice=='Q')
     exit(1);
    else if(choice=='S')
    {
     system("cls");

    printf("nnnnnnnnnntttResister your name:");
     gets(playername);

    system("cls");
    printf("n ------------------  Welcome %s to C Program Quiz Game --------------------------",playername);
    printf("nn 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 $100,000!");
    printf("n    By this way you can win upto ONE MILLION cash prize!!!!!..........");
    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");
    printf("n >> No negative marking for wrong answers!");
    printf("nnt!!!!!!!!!!!!! ALL THE BEST !!!!!!!!!!!!!");
    printf("nnn Press Y  to start the game!n");
    printf("n Press any other key to return to the main menu!");
    if (toupper(getch())=='Y')
          {
              goto home;
        }
     else
          {
        goto mainhome;
       system("cls");
       }

     home:
     system("cls");
     count=0;
     for(i=1;i<=3;i++)
     {
    system("cls");
     r1=i;


     switch(r1)
          {
          case 1:
          printf("nnFor which of the following disciplines is Nobel Prize awarded?");
          printf("nnA.Physics and ChemistryttB.Physiology or MedicinennC.Literature, Peace and EconomicsttD.All of the above");
          if (toupper(getch())=='D')
               {
                   printf("nnCorrect!!!");count++;
                   getch();
                   break;
}
          else
                 {
                     printf("nnWrong!!! The correct answer is D");
                     getch();
                 break;
                 }

        case 2:
          printf("nnnFFC stands for");
          printf("nnA.Foreign Finance CorporationttB.Film Finance CorporationnnC.Federation of Football CouncilttD.     None of the above");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");count++;
               getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is B");
                 getch();
                 break;}

        case 3:
          printf("nnn First Afghan War took place in?");
          printf("nnA.1839ttB.1843nnC.1833ttD.1848");
          if (toupper(getch())=='A')
               {printf("nnCorrect!!!");count++;
               getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is A ");
                 getch();
                 break;}

        case 4:
          printf("nnnFirst China War was fought between?");
          printf("nnA.China and BritainttB.China and FrancennC.China and EgyptttD.China and Greek");
          if (toupper(getch())=='A')
               {printf("nnCorrect!!!");count++;
               getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is A ");
                 getch();
                 break;}

        case 5:
        printf("nnnEach year World Red Cross and Red Crescent Day is celebrated on?");
        printf("nnA.ttB.nnC.ttD.");
        if (toupper(getch())=='A')
               {printf("nnCorrect!!!");count++;
               getch();
                break;}
        else
                 {printf("nnWrong!!! The correct answer is A");
                 getch();
                 break;}

        case 6:
          printf("nnn");
          printf("nnA.May 8ttB.May 18nnC.June 8ttD.June 18");
          if (toupper(getch())=='A' )
               {printf("nnCorrect!!!");count++;
               getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is A ");
                 getch();
                 break;}}
                 }

     if(count>=2)
     {goto test;}
     else
     {
     system("cls");
     printf("nnSORRY YOU ARE NOT ELIGIBLE TO PLAY THIS GAME, BETTER LUCK NEXT TIME");
     getch();
     goto mainhome;
     }
     test:
     system("cls");
     printf("nnt*** CONGRATULATION %s you are eligible to play the Game ***",playername);
     printf("nnnnt!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;

     switch(r)
          {
          case 1:
          printf("nnFilm and TV institute of India is located at?");
          printf("nnA.Pune (Maharashtra)ttB.Rajkot (Gujarat)nnC.Pimpri (Maharashtra)ttD.Perambur (Tamilnadu)");
          if (toupper(getch())=='A')
               {printf("nnCorrect!!!");countr++;getch();
                break;getch();}
          else
                 {printf("nnWrong!!! The correct answer is A");getch();
                 goto score;
                 break;}

          case 2:
          printf("nnnWhich was the 1st non Test playing country to beat India in an international match");
          printf("nnA.CanadattB.Sri Lanka      nnC.ZimbabwettD.East Africa");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is  B");getch();
                goto score;
                 break;
                 }

        case 3:
          printf("nnnWho was the first Indian to win the World Amateur Billiards title? ");
          printf("nnA.Geet SethittB.Wilson JonesnnC.Michael FerreirattD.Manoj Kothari");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is B");getch();
                 goto score;
                 break;}

        case 4:
          printf("nnnWhen was Amateur Athletics Federation of India established?");
          printf("nnA.1936ttB.1946nnC.1956ttD.1966");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {
                printf("nnWrong!!! The correct answer is B");getch();
                 goto score;
                 break;
                 }

        case 5:
          printf("nnnWhich NBA player scored 8 points in the final 7 seconds of a game to lead his team to victory?");
          printf("nnA.Baron DavisttB.Kevin GarnettnnC.Stephon MaurburyttD.Reggie Miller");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++;getch(); break;}
          else
                 {
                     printf("nnWrong!!! The correct answer is D");
                 getch();
                 goto score;
                 break;
                 }

          case 6:
          printf("nnnThe nickname of Glenn McGrath is what?");
          printf("nnA.     Ooh AhhttB.PenguinnnC.Big BirdttD.Pigeon");
          if (toupper(getch())=='D' )
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is D");goto score;
                 getch();
                 break;}

        case 7:
          printf("nnnThe nickname of Glenn McGrath is what?");
          printf("nnA.ttB.nnC.ttD.");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is D.Nippon");getch();
                 goto score;
                 break;}

        case 8:
          printf("nnnWhat does VVVF stand for??");
          printf("nnA.Variant Voltage Vile FrequencyttB.     Variable Velocity Variable FunnnC.Very Very Vicious FrequencyttD.Variable Voltage Variable Frequency");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++;getch(); break;}
          else
                 {printf("nnWrong!!! The correct answer is D");getch();
                 goto score;
                 break;}

        case 9:
          printf("nnnIn which decade was the American Institute of Electrical Engineers (AIEE) founded?");
          printf("nnA.1850sttB.1880snnC.1930sttD.1950s");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is B");getch();
                 goto score;
                 break;}

        case 10:
          printf("nnnWho developed Yahoo??");
          printf("nnA.     Dennis Ritchie & Ken ThompsonttB.David Filo & Jerry YangnnC.Vint Cerf & Robert KahnttD.Steve Case & Jeff Bezos");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++;getch(); break;}
          else
                 {printf("nnWrong!!! The correct answer is B");getch();break;goto score;}

        case 11:
          printf("nnnWhat is the color of the Black Box in aeroplanes?");
          printf("nnA.WhitettB.BlacknnC.OrangettD.Red");
          if (toupper(getch())=='C')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
              {printf("nnWrong!!! The correct answer is C.Orange");getch();
              break;goto score;}

        case 12:
          printf("nnnWhich city is known at 'The City of Seven Hills'?");
          printf("nnA.RomettB.Vactican CitynnC.MadridttD.Berlin");
          if (toupper(getch())=='A')
                 {printf("nnCorrect!!!");countr++;getch();
                  break;}
          else
              {printf("nnWrong!!! The correct answer is A.Rome");getch();
              break;goto score;}

          case 13:
          printf("nnnName the country where there no mosquitoes are found?");
          printf("nnA.JapanttB.ItalynnC.ArgentinattD.France");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++;getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is D.France");getch();
                 break;goto score;}

        case 14:
          printf("nnnWho is the author of 'Pulpasa Cafe'?");
          printf("nnA.Narayan WaglettB.Lal Gopal SubedinnC.B.P. KoiralattD.Khagendra Sangraula");
          if (toupper(getch())=='A')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is A.Narayan Wagle");getch();
                 break;goto score;}

          case 15:
          printf("nnnWhich Blood Group is known as the Universal Recipient?");
          printf("nnA.AttB.ABnnC.BttD.O");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++;getch();
                break;}
          else
                 {printf("nnWrong!!! The correct answer is B.AB");getch();
                 goto score;
                 break;}

          case 16:
          printf("nnnWhat is the unit of measurement of distance between Stars?");
          printf("nnA.Light YearttB.CoulombnnC.Nautical MilettD.Kilometer");
          if (toupper(getch())=='A')
               {printf("nnCorrect!!!");countr++; getch();
               break;
               }
          else
                 {printf("nnWrong!!! The correct answer is A.Light Year");getch();
                 goto score;
                 break;}


          case 17:
          printf("nnnThe country famous for Samba Dance is........");
          printf("nnA.BrazilttB.VenezuelannC.NigeriattD.Bolivia");
          if (toupper(getch())=='A')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is A.Brazil");getch();goto score;
                 break;}

          case 18:
          printf("nnnWind speed is measure by__________?");
          printf("nnA.LysimeterttB.Air vanennC.HydrometerttD.Anemometernn");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is D.Anemometer");getch();goto score;
                 break;}

          case 19:
          printf("nnnWhich city in the world is popularly known as The City of Temple?");
          printf("nnA.DelhitB.BhaktapurnnC.KathmandutD.Agrann");
          if (toupper(getch())=='C')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is C.Kathmandu");getch();goto score;
                 break;}

          case 20:
          printf("nnnWhich hardware was used in the First Generation Computer?");
          printf("nnA.TransistorttB.ValvesnnC.I.CttD.S.S.I");
          if (toupper(getch())=='B')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is B.Valves");getch();goto score;
                 break;}

          case 21:
          printf("nnnOzone plate is being destroyed regularly because of____ ?");
          printf("nnA.L.P.GttB.NitrogennnC.MethanettD. C.F.C");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is D. C.F.C");getch();goto score;
                 break;}

          case 22:
          printf("nnnWho won the Women's Australian Open Tennis in 2007?");
          printf("nnA.Martina HingisttB.Maria SarapovannC.Kim ClijsterttD.Serena Williams");
          if (toupper(getch())=='D')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is D.Serena Williams");getch();goto score;
                 break;}

          case 23:
          printf("nnnWhich film was awarded the Best Motion Picture at Oscar in 2010?");
          printf("nnA.The Secret in their EyesttB.Shutter IslandnnC.The King's SpeechttD.The Reader");
          if (toupper(getch())=='C')
               {printf("nnCorrect!!!");countr++; getch();
               break;}
          else
                 {printf("nnWrong!!! The correct answer is C.The King's Speech");getch();goto score;
                 break;}}}
     score:
    system("cls");
     score=(float)countr*100000;
     if(score>0.00 && score<1000000)
     {
        printf("nntt**************** CONGRATULATION *****************");
          printf("nt You won $%.2f",score);goto go;}

      else if(score==1000000.00)
     {
         printf("nnn tt**************** CONGRATULATION ****************");
         printf("ntttt YOU ARE A MILLIONAIRE!!!!!!!!!");
         printf("ntt You won $%.2f",score);
         printf("tt Thank You!!");
     }
      else
{
      printf("nnt******** SORRY YOU DIDN'T WIN ANY CASH ********");
         printf("ntt Thanks for your participation");
         printf("ntt TRY AGAIN");goto go;}

     go:
     puts("nn Press Y if you want to play next game");
     puts(" Press any key if you want to go main menu");
     if (toupper(getch())=='Y')
          goto home;
     else
          {
          edit_score(score,playername);
          goto mainhome;}}}

void show_record()
    {system("cls");
     char name[20];
     float scr;
     FILE *f;
     f=fopen("score.txt","r");
     fscanf(f,"%s%f",&name,&scr);
     printf("nntt*************************************************************");
     printf("nntt %s has secured the Highest Score %0.2f",name,scr);
     printf("nntt*************************************************************");
     fclose(f);
     getch();}

void reset_score()
    {system("cls");
    float sc;
     char nm[20];
     FILE *f;
     f=fopen("score.txt","r+");
     fscanf(f,"%s%f",&nm,&sc);
     sc=0;
     fprintf(f,"%s,%.2f",nm,sc);
    fclose(f);}

void help()
     {system("cls");
    printf("nn                              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 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("nnt*********************BEST OF LUCK*********************************");
     printf("nnt*****C PROGRAM QUIZ GAME is developed by CODE WITH C TEAM********");}

void edit_score(float score, char plnm[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,"%sn%.2f",plnm,sc);
         fclose(f);}}

          
Comments: