Search This Blog

Wednesday, February 13, 2013

QUIZ

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
void showrecord(void);
void resetscr()
{float sc;
    char nm[20];
    FILE *f;
    f=fopen("score.txt","r+");
    fscanf(f,"%s%f",&nm,&sc);
    sc=0;
    fprintf(f,"%s,%5.2f",nm,sc);
    fclose(f);
}
void help()
    {
    printf("HELP");
    printf("\n\n\n\tThis test \"AAJMA LUCK\" is a game of luck and knowledge. You'll be asked");
    printf("\n\n\tsome I.Q.questions with 4 options and the right answer is to be chosen ");
    printf("\n\n\tamong them.you will be asked until you give incorrect answer.Your score ");
    printf("\n\n\twill be calculated at end and displayed. If you secure highest score, ");
    printf("\n\n\tyour score will be recorded and you will be awardedaccordlingly.");
    printf("\n\n\t*********************BEST OF LUCK*********************************");
    }
void editscore(float score, char plnm[20])
    {
    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",plnm,sc);
        fclose(f);
      }
    }
int main()
     {
     int countr;
     int r,i,n;
        float score;
     char choice;
     char playername[20];
     mainhome:
     printf("\n\n\n\n\t\t\t  W   L   O   E  T \n");
     printf("\t\t\t    E   C   M      O");
     printf("\n\n\n\t\t\t     AAJMA LUCK \n\n") ;
     printf("\n\t\t********************************");
     printf("\n\n\n\t\t # press 'S' to start the test       ");
     printf("\n\t\t # press 'V' to view high 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\n\n\t\t********************************\n\n\t\t  ");
     choice=toupper(getch());
     if (choice=='V')
    {
    showrecord();
    goto mainhome;
    }
     else if (choice=='Q')
    exit(1);
     else if (choice=='H')
    {
    help();
    getch();
    goto mainhome;
    }
    else if (choice=='R')
    {resetscr();
    getch();
    goto mainhome;}
    else if(choice=='S'){


     printf("\n\n\n\t\t\tEnter your name...");
     gets(playername);

     home:
     countr=0;
     i=1;
     start:
     r=rand()%24;

     switch(r)
        {
        case 1:
        printf("\n\nSome months have 30 days, some months have 31 days. How many months have 28 days?");
        printf("\n\nA.4\tB.3\n\nC.1\tD.none\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.1");

               break;}getch();
               goto go;

        case 2:
        printf("\n\n\nIf a doctor gives you 3 pills and tells you to take one pill every half hour,");
        printf(" how long would it be before all the pills had been taken?");
        printf("\n\nA.4\tB.1 and half\n\nC.3\tD.1\n\n");
        if (toupper(getch())=='D')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               printf("\n\nWrong!!! The correct answer is D.1");getch();
               goto go;
        break;

        case 3:
        printf("\n\n\nDivide 30 by half and add ten. What do you get? ");
        printf("\n\nA.25\tB.40\n\nC.30\tD.70\n\n");
        if (toupper(getch())=='D')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is D.70");getch();
               goto go;break;}


        case 4:
        printf("\n\n\nA farmer had 17 sheep. All but 9 died. How many live sheep were left?");
        printf("\n\nA.9\tB.17\n\nC.8\tD.0\n\n");
        if (toupper(getch())=='A')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is A.9");getch();
               goto go;break;}


        case 5:
        printf("\n\n\nTake 2 apples from 3 apples. What do you have? ");
        printf("\n\nA.1\tB.3\n\nC.2\tD.5\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.2");
               getch();
               goto go;
               break;}

        case 6:
        printf("\n\n\nWhich syllabe is stressed in the word 'democracy'?");
        printf("\n\nA.1st\tB.2nd\n\nC.3rd\tD.4th\n\n");
        if (toupper(getch())=='B' )
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is B.2nd");getch();
               goto go;break;}


        case 7:
        printf("\n\n\nWhich country was the winner of Cricket World Cup 2011?");
        printf("\n\nA.Sri Lanka\tB.India\n\nC.Australia\tD.Pakistan\n\n");
        if (toupper(getch())=='B')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is B.India");getch();
               goto go;break;}


        case 8:
        printf("\n\n\nWhat is the height of Mount everest in meter?");
        printf("\n\nA.8648\tB.6648\n\nC.8884\tD.8848\n\n");
        if (toupper(getch())=='D')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is D.8848");getch();
               goto go;break;}


        case 9:
        printf("\n\n\nWhat is the capital of Denmark?");
        printf("\n\nA.Copenhagen\tB.Helsinki\n\nC.Rome\t\tD.Madrid\n\n");
        if (toupper(getch())=='A')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is A.Copenhagen");getch();
               goto go;break;}


        case 10:
        printf("\n\n\nWhich syllabe is stressed in the word 'instanteneous'?");
        printf("\n\nA.1st\tB.2nd\n\nC.3rd\tD.4th\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.3rd");getch();
               goto go;break;}


        case 11:
        printf("\n\n\nWho was the only player to score 6 successive sixes in an over?");
        printf("\n\nA.Adam Gilchrist\tB.M.S.Dhoni\n\nC.Herschel Gibbs\tD.Sanath Jayasurya\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.Herschel Gibbs");getch();
               goto go;break;}

        case 12:
        printf("\n\n\nWho was the only player to take 4 successive wickets?");
        printf("\n\nA.Malinga Bandara\tB.Lasith Malinga\n\nC.Bret Lee\tD.Murali Daran\n\n");
        if (toupper(getch())=='B')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is B.Lasith Malinga");getch();
               goto go;break;}

        case 13:
        printf("\n\n\nWhich country is hosting the Fifa World Cup 2010?");
        printf("\n\nA.South Africa\tB.Italy\n\nC.Argentina\tD.Spain\n\n");
        if (toupper(getch())=='A')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is A.South Africa");getch();
               goto go;break;}

        case 14:
        printf("\n\n\nWho is the author of 'Pulpasa Cafe'?");
        printf("\n\nA.Narayan Wagle\tB.Lal Gopal Subedi\n\nC.B.P. Koirala\tD.Khagendra Sangraula\n\n");
        if (toupper(getch())=='A')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is A.Narayan Wagle");getch();
               goto go;break;}

        case 15:
        printf("\n\n\nWhich country is Maria Sarapova from?");
        printf("\n\nA.Russia\tB.Switzerland\n\nC.Argentina\tD.Spain\n\n");
        if (toupper(getch())=='A')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is A.Russia");getch();
               goto go;break;}

        case 16:
        printf("\n\n\nWho was awarded the youngest player award in Fifa World Cup 2006?");
        printf("\n\nA.Wayne Rooney\tB.Lucas Podolski\n\nC.Lionel Messi\tD.Christiano Ronaldo\n\n");
        if (toupper(getch())=='B')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is B.Lucas Podolski");getch();
               goto go;break;}


        case 17:
        printf("\n\n\nWhat is the smallest district of Nepal?");
        printf("\n\nA.Lalitpur\tB.Kalikot\n\nC.Bhaktapur\tD.Gulmi\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.Bhaktapur");getch();
               goto go;break;}

        case 18:
        printf("\n\n\nWhat is the headquarter of Western Development Region?");
        printf("\n\nA.Dhankuta\tB.birendranagar\n\nC.Dhangadhi\tD.Pokhara\n\n");
        if (toupper(getch())=='D')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is D.Pokhara");getch();
               goto go;break;}

        case 19:
        printf("\n\n\nWhich place is called 'The Cherrapunji of Nepal'?");
        printf("\n\nA.Dharan\tB.Kathmandu\n\nC.Pokhara\tD.Butwal\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.Pokhara");getch();
               goto go;break;}

        case 20:
        printf("\n\n\nWhich city is known at 'The City of Seven Hills'?");
        printf("\n\nA.Rome\tB.Vactican City\n\nC.Madrid\tD.Berlin\n\n");
        if (toupper(getch())=='A')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is A.Rome");getch();
               goto go;break;}

        case 21:
        printf("\n\n\nWho was the F1 racing champion of 2006?");
        printf("\n\nA.Louis Hamilton\tB.Felipe Massa\n\nC.Fernando Alonso\tD.Michael Schumaker\n\n");
        if (toupper(getch())=='C')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is C.Fernanda Alonso");getch();
               goto go;break;}

        case 22:
        printf("\n\n\nWho won the Women Australian Open 2007?");
        printf("\n\nA.Martina Hingis\tB.Maria Sarapova\n\nC.Kim Clijster\tD.Serena Williams\n\n");
        if (toupper(getch())=='D')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is D.Serena Williams");getch();
               goto go;break;}

        case 23:
        printf("\n\n\nName the country where there no mosquito is found?");
        printf("\n\nA.Germany\tB.Spain\n\nC.Japan\tD.France\n\n");
        if (toupper(getch())=='D')
            {printf("\n\nCorrect!!!");countr++; break;}
        else
               {printf("\n\nWrong!!! The correct answer is D.France");getch();
               goto go;break;}



        }
    i++;
    if (i<=10) goto start;
    else
    score=(float)countr/10*100;
    score:
    score=(float)countr/10*100;
    printf("\n\n\nYour Score: %.2f",score);
    if (score==100) printf("\n\nCONGRATULATIONS...YOU WON THE FIRST PRIZE");
    else if (score>=80 && score<100) printf("\n\nVERY GOOD!!");
    else if (score>=60 &&score<80) printf("\n\nGOOD! BUT YOU NEED TO KNOW MORE.");
    else if (score>=40 && score<60) printf("\n\nSATISFACTORY RESULT, BUT THIS MUCH IS MUCH SUFFICIENT.");
    else printf("\n\nYOU ARE VERY POOR IN I.Q.,WORK HARD");
    puts("\n\nNEXT PLAY?(Y/N)");
    if (toupper(getch())=='Y')
        goto home;
    else
        {
        editscore(score,playername);
        goto mainhome;
        }
    }
     else
    {
    printf("\n\n\t\t  Invalid Entry\n\n\t\t  ");

    goto mainhome;
    }
    go:
    goto score;

      }
void showrecord()
    {
    char name[20];
    float s;
    FILE *f;
    f=fopen("score.txt","r");
    fscanf(f,"%s%f",&name,&s);
    printf("\n\n\t\t***********************************************");
    printf("\n\n\t\t %s has secured the Highest Score %.2f",name,s);
    printf("\n\n\t\t***********************************************");
    fclose(f);
    getch();
    }