Quiz: 50 Country Capitals

By informaticar on Oct 26, 2008

I just finished with my quiz on macedonian language. Computer ask you "what is capital of ...?" and you need to answer on this question. If you have 3 incorrect answer, the game is over and you lose. For now its on macedonian, I'll translate it on English tomorrow.
Image

/ Coded by informaticar
#include <String.h>
#include <Stdlib.h>
#include <Stdio.h>
#include <Time.h>

char State[50][255] = {"Albanija",
                       "Andora",
                       "Ermenia",
                       "Austrija",
                       "Azerbedzan",
                       "Belorusija",
                       "Belgija",
                       "Bosna i Hercegovina",
                       "Bugarija",
                       "Hrvatska",
                       "Kipar",
                       "Ceska",
                       "Danska",
                       "Estonia",
                       "Finska",
                       "Francija",
                       "Germanija",
                       "Grcija",
                       "Ungarija",
                       "Island",
                       "Irska",
                       "Italija",
                       "Kazahstan",
                       "Latvija",
                       "Lihtenstajn",
                       "Luksemburg",
                       "MAKEDONIJA",
                       "Malta",
                       "Moldavija",
                       "Crna Gora",
                       "Holandija",
                       "Monako",
                       "Holandija",
                       "Norveska",
                       "Polska",
                       "Portugalija",
                       "Romanija",
                       "Rusija",
                       "Srbija",
                       "Slovacka",
                       "Slovenija",
                       "Shpanija",
                       "Shvedska",
                       "Shvajcarija",
                       "Turcija",
                       "Ukraina",
                       "Velika Britanija",
                       "Vels",
                       "Vatikan",
                       "Kosovo"};

char Capital[50][255] = {"Tirana",
                         "Andora La Vella",
                         "Jerevan",
                         "Viena",
                         "Baku",
                         "Minsk",
                         "Brisel",
                         "Sarajevo",
                         "Sofia",
                         "Zagreb",
                         "Nikosia",
                         "Praga",
                         "Kopenhagen",
                         "Talin",
                         "Helsinki",
                         "Pariz",
                         "Berlin",
                         "Atina",
                         "Budimpeshta",
                         "Rejkjavik",
                         "Dablin",
                         "Roma",
                         "Astana",
                         "Riga",
                         "Vaduz",
                         "Luksemburg Siti",
                         "Sopje",
                         "Valeta",
                         "Chisinau",
                         "Podgorica",
                         "Amsterdam",
                         "Monako",
                         "Amsterdam",
                         "Oslo",
                         "Varshava",
                         "Lisabon",
                         "Bukuresht",
                         "Moskva",
                         "Belgrad",
                         "Bratislava",
                         "Ljubljana",
                         "Madrid",
                         "Stokholm",
                         "Bern",
                         "Ankara",
                         "Kiev",
                         "London",
                         "Kardif",
                         "Vatikan",
                         "Prishtina"};

int main()
{
    srand(time(0));

    int NumCorrect   = 0;
    int NumIncorrect = 0;

    while(true)
    {
        int RandNum = rand() % 49;

        if(!strlen(State[RandNum]))
        {
            while(!strlen(State[RandNum]))
            {
                RandNum = rand() % 49;
            }
        }

        char Answer[255];
        char Buffer[255];

        sprintf(Buffer, "Koj e glaven grad na %s?", State[RandNum]);
        puts(Buffer);
        gets(Answer);

        if(!strcmp(Answer, Capital[RandNum]))
        {
            NumCorrect ++;

            if(NumCorrect == 50)
            {
                puts("Gi pogodi site glavni gradovi na 50te drzavi!\n"
                     "Ti si POBEDNIK!!! (-:");

                system("pause");

                exit(EXIT_SUCCESS);
            }

            strcpy(State[RandNum], "");
            strcpy(Capital[RandNum], "");
            printf("%s, e tocen odgovor! Bravo!\n", Answer);
        }
        else
        {
            NumIncorrect ++;

            if(NumIncorrect == 3)
            {
                puts("Imase 3 netocni odgovori.\n"
                     "Ti izgubi!!! )-:");

                system("pause");

                exit(EXIT_SUCCESS);
            }

            printf("%s, ne e tocen odgovor. Tocniot odgovor bese %s.\n", Answer, Capital[RandNum]);
        }

        printf("Tvojot rezultat e:\n"
               "Tocni      : %i\n"
               "Pogreshni    : %i\n\n", NumCorrect, NumIncorrect);

        system("pause");
        system("cls");
    }

    system("pause");

    return(0);
}

Comments

Sign in to comment.
Hawkee   -  Oct 27, 2008

You could even have this take in quiz data in the form of a text file. Just pair up questions and answers. Not bad though.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.