Tuesday 8 February 2011

source code of kaun banega lakhpati game

Code :
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<graphics.h>
void draw_screen();
void end_cong();
void sound_p1();
void sound_cong();
void main()
{
    int chosen,ans,act,act1,m; long int money;
    int qqq;
    m=0;money=0;
    randomize();
    draw_screen();
    textcolor(YELLOW);
    printf("T H I S  P R O G R A M  H A S  B E E N  M A D E  B Y:
 S U C
H
A N");
    sound_p1();
    printf("



enter your bank account number:");
    scanf("%d",&qqq);
    for(int n=1;n<=12;n=n+1)
    {
        clrscr();
        chosen=random(25);
        switch(chosen)
        {
            case 0:
                    gotoxy(35,10);  cprintf("WHEN WAS ABRAHAM LINCOLN ASSASINATED ?");
                    gotoxy(35,12);  cprintf("1.1865             3.1871");
                    gotoxy(35,13);  cprintf("2.1866             4.1800");
                    act=1;
                    break;

            case 1:
                    gotoxy(35,10);  cprintf("WHEN WAS ABRAHAM LINCOLN ASSASINATED ?");
                    gotoxy(35,12);  cprintf("1.1865             3.1871");
                    gotoxy(35,13);  cprintf("2.1866             4.1800");
                    act=1;
                    break;
            case 2:
                    gotoxy(35,10);  cprintf("WHO GAVE THE SLOGON 'DO OR DIE'?");
                    gotoxy(35,12);  cprintf("1.GEORGE BUSH      3.LALJI PRASAD");
                    gotoxy(35,13);  cprintf("2.MAHATMA GANDHI   4.SALMAN KHAN");
                    act=2;
                    break;
            case 3:
                    gotoxy(35,10);  cprintf("WHO INTRODUCED INDRAJATRA IN NEPAL ?");
                    gotoxy(35,12);  cprintf("1.PRATAP SINGH     3.GUNAKAMADEVA");
                    gotoxy(35,13);  cprintf("2.JAY PRAKASH      4.NARENDRADEVA");
                    act=3;
                    break;
            case 4:
                    gotoxy(35,10);  cprintf("WHO ESTABLISHED 'DAKSHINKALI'?");
                    gotoxy(35,12);  cprintf("1:JAYA PRAKASH     3.SADAR SINGH");
                    gotoxy(35,13);  cprintf("2.AMARSHIN THAPA   4.PRATAP MALLA");
                    act=4;
                    break;
            case 5:
                    gotoxy(35,10);  cprintf("FATHER OF COMPUTER");
                    gotoxy(35,12);  cprintf("1:charles babbage  3.you");
                    gotoxy(35,13);  cprintf("2.buwank.c.        4.tribuwan");
                    act=1;
                    break;
            case 6:
                    gotoxy(35,10);  cprintf("HOW FAR IS NEPAL FROM SEA?");
                    gotoxy(35,12);  cprintf("1.5362             3.100");
                    gotoxy(35,13);  cprintf("2.1127             4.5213");
                    act=2;
                    break;

            case 7:
                    gotoxy(35,10);  cprintf("WHICH IS THE LARGEST DISTRICT OF NEPAL");
                    gotoxy(35,12);  cprintf("1.ROLPA            3.DOLPA");
                    gotoxy(35,13);  cprintf("2.PALPA            4.MALPA");
                    act=3;
                    break;
            case 8:
                    gotoxy(35,10);  cprintf("LAND OF EXTREMES...");
                    gotoxy(35,12);  cprintf("1.EUROPE           3.AUSTRALIA");
                    gotoxy(35,13);  cprintf("2.AFRICA           4.ASIA");
                    act=4;
                    break;
            case 9:
                    gotoxy(35,10);  cprintf("LAND OF DARKNESS...");
                    gotoxy(35,12);  cprintf("1.AFRICA           3.EUROPE");
                    gotoxy(35,13);  cprintf("2.ASIA             4.AUSTRALIA");
                    act=1;
                    break;
            case 10:
                    gotoxy(35,10);  cprintf("NEW WORLD...");
                    gotoxy(35,12);  cprintf("1.NORTH KOREA      3.SOUTH KOREA");
                    gotoxy(35,13);  cprintf("2.NORTH AMERICA    4.SOUTH AMERICA");
                    act=2;
                    break;
            case 11:
                    gotoxy(35,10);  cprintf("LAND OF TAMPLES....");
                    gotoxy(35,12);  cprintf("1.CHINA            3.NEPAL");
                    gotoxy(35,13);  cprintf("2.INDIA            4.PAKISTAN");
                    act=3;
                    break;
            case 12:
                    gotoxy(35,10);  cprintf("WHEN DID WORLD WAR II ENDED?");
                    gotoxy(35,12);  cprintf("1:1948             3.1940");
                    gotoxy(35,13);  cprintf("2.1952             4.1945");
                    act=4;
                    break;
            case 13:
                    gotoxy(35,10);  cprintf("KABUL IS THE CAPITAL OF");
                    gotoxy(35,12);  cprintf("1:AFGANISTAN       3.BANGLADESH");
                    gotoxy(35,13);  cprintf("2.ALGIORS          4.ARGENTINA");
                    act=1;
                    break;
            case 14:
                    gotoxy(35,10);  cprintf("BIG B. IS...");
                    gotoxy(35,12);  cprintf("1:ABISAKH B.       3.SHARUKH B.");
                    gotoxy(35,13);  cprintf("2.AMITAB B.        4.KABINDER B.");
                    act=2;
                    break;
            case 15:
                    gotoxy(35,10);  cprintf("BRAZIL'S CAPITAL...");
                    gotoxy(35,12);  cprintf("1:BRAZILLA         3.BRACILIA");
                    gotoxy(35,13);  cprintf("2.BRACILL          4.BRACOLIO");
                    act=3;
                    break;
            case 16:
                    gotoxy(35,10);  cprintf("YOUTH YEAR.... ");
                    gotoxy(35,12);  cprintf("1:1982             3.1984");
                    gotoxy(35,13);  cprintf("2.1983             4.1985");
                    act=4;
                    break;
            case 17:
                    gotoxy(35,10);  cprintf("FILL IN THE BLANK,16TH______");
                    gotoxy(35,12);  cprintf("1.DEC              3.JULY");
                    gotoxy(35,13);  cprintf("2.JAN              4.FEB");
                    act=1;
                    break;
            case 18:
                    gotoxy(35,10);  cprintf("GUN POWDER WAS FIRST USED IN.");
                    gotoxy(35,12);  cprintf("1:NEPAL            3.AMERICA");
                    gotoxy(35,13);  cprintf("2.CHINA            4.INDIA");
                    act=2;
                    break;
            case 19:
                    gotoxy(35,10);  cprintf("IN 5 RING,WHICH REPRESENT ASIA");
                    gotoxy(35,12);  cprintf("1:BLUE             3.YELLOW");
                    gotoxy(35,13);  cprintf("2.GREEN            4.RED");
                    act=3;
                    break;
            case 20:
                    gotoxy(35,10);  cprintf("INVENTER OF REMOTE CONTROL PROCESS..");
                    gotoxy(35,12);  cprintf("1.SIR S.MAXIM      3.SARETY RAZOR");
                    gotoxy(35,13);  cprintf("2.HARRY BERRY      4.A.M.LOW");
                    act=4;
                    break;
            case 21:
                    gotoxy(35,10);  cprintf("WHO WAS THE FIRST PERSON TO SAY'JAY
NEPAL'
");
                    gotoxy(35,12);  cprintf("1:SHUKRARAJ SHASTRI3.PRITHIVI NARAYAN
SHAH");
                    gotoxy(35,13);  cprintf("2.RAN BAHADUR SHAH 4.DHARMA BHAKTA
MATHEMA");
                    act=1;
                    break;
            case 22:
                    gotoxy(35,10);  cprintf("WHICH KING UNIFIED NEPAL?");
                    gotoxy(35,12);  cprintf("1.BHUPATENDRA MALLA3.RANJIT MALLA");
                    gotoxy(35,13);  cprintf("2.PRITHIVI NARAYAN 4.PRATAP MALLA");
                    act=2;
                    break;
            case 23:
                    gotoxy(35,10);  cprintf("WHEN WAS SUNDHARA BUILT? ");
                    gotoxy(35,12);  cprintf("1.1881 A.D         3.1885 A.D");
                    gotoxy(35,13);  cprintf("2.1883 A.D         4.1887 A.D");
                    act=3;
                    break;
            case 24:
                    gotoxy(35,10);  cprintf("WHO BUILT THE GOLDEN TAP? ");
                    gotoxy(35,12);  cprintf("1.PRAKASH THAPA    3.AMARSHING THAPA");
                    gotoxy(35,13);  cprintf("2.SUBASH THAPA     4.BHIMSEN THAPA");
                    act=4;
                    break;

            case 25:
                    gotoxy(35,10);  cprintf("WHAT IS KHOKANA FAMOUS FOR? ");
                    gotoxy(35,12);  cprintf("1.OIL              3.VEGETABLE");
                    gotoxy(35,13);  cprintf("2.GHEE             4.RICE");
                    act=1;
                    break;

        }

        printf("
");
        scanf("%d",&ans);

        if(ans==0)
        {
             if(m<3)
             {
            switch(act)
            {
                case 1:gotoxy(53,12);    cprintf("                        ");
                         gotoxy(53,13);    cprintf("                        ");
                         break;
                case 2:gotoxy(34,12);    cprintf("                 ");
                         gotoxy(53,13);    cprintf("                        ");
                         break;
                case 3:gotoxy(35,12);    cprintf("                 ");
                         gotoxy(35,13);    cprintf("                 ");
                         break;
                case 4:gotoxy(53,12);    cprintf("                         ");
                         gotoxy(35,13);    cprintf("                 ");
                         break;
             }
                    m=m+1;
                    printf("
");
                    scanf("%d",&ans);
             }
             else
             {
            printf("Sorry,NO 50-50 left,but you can call your friend");
            scanf("%d",&ans);
            if(ans==0)n=13;
             }
        }
        if(ans==act)
        {
            money+=1000;

            printf("Correct,You have won ");
            printf("Rs.%d0",money);
            if(money==12000)
            {
                end_cong();
                getch();
            }
        }
        if(ans!=act&&ans!=0&&ans!=5)
        {
            delay(300);
            printf("afos,you lose

");


            if(money<4000)
            printf("You have won nothing");
            else if(money==4000||money<8000)
            printf("You have won RS.40000");
            else if(money==8000||money<12000)
            printf("WOW!,You have won RS.80000");
            if(money>4000)
            printf("

 your money has been transferred to your bank account");



            getch();
            n=13;
        }
        if(ans==5)
        {
            printf("You have won

");
            delay(300);
            printf("Rs.a%d0",money);
            n=13;
        }
        getch();
    }
}
void end_cong()
{
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\tc\bgi");
    int x,y;
    x=getmaxx()/2;
    y=getmaxy()/2;

    for(int i=1;i<=6;i++)
    {
        clrscr();
        setcolor(i);
        settextstyle(GOTHIC_FONT,HORIZ_DIR,i);
        outtextxy(x-300,y-200,"CONGRATULATION");
        delay(300);
    }
    settextstyle(GOTHIC_FONT,HORIZ_DIR,3);
    setcolor(RED);
    outtextxy(x-320,y,"You got it all");
    outtextxy(x-320,y+20,"Your money has been transfered to your bank
account....");
    sound_cong();
    nosound();
    delay(500);
    closegraph();
}
void draw_screen()
{
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\tc\bgi");
    int x,y,w;
    x=getmaxx()/2;
    y=getmaxy()/2;
    for(w=0;w<50;w++)

    {
    setcolor(w);
    setfillstyle(SOLID_FILL,w);
    rectangle(x-200,y-75,x-175,y+75);
    floodfill(x-180,y,w);
    line(x-175,y,x-100,y-75);
    line(x-175,y,x-100,y+75);
    rectangle(x-50,y-75,x-25,y+75);
    floodfill(x-35,y,w);
    ellipse(x-25,y-35,270,90,75,34);
    ellipse(x-25,y+35,270,90,75,34);
    rectangle(x+175,y-75,x+150,y+75);
    floodfill(x+165,y,w);
    rectangle(x+175,y+50,x+225,y+75);
    floodfill(x+180,y+60,w);

    setfillstyle(SOLID_FILL,w);
    circle(x-300,y-250,25);
        floodfill(x-300,y-250,w);
    circle(x+300,y-250,25);
        floodfill(x+300,y-250,w);
    circle(x+300,y+250,25);
        floodfill(x-300,y+250,w);
    circle(x-300,y+250,25);
        floodfill(x-300,y+250,w);


    setfillstyle(SOLID_FILL,w);
    circle(x-250,y-150,50);
    floodfill(x-250,y-150,w);
    circle(x+250,y-150,50);
    floodfill(x+250,y-150,w);
    circle(x-250,y+150,50);
    floodfill(x-250,y+150,w);
    circle(x+250,y+150,50);
    floodfill(x+250,y+150,w);
    outtextxy(x-200,y+100,"                 KAUN BANEGA LAKHPATI");
    }

clrscr();
settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
setcolor(BLUE);
outtextxy(x-150,y-200,"INSTRUCTION");
setcolor(RED);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(x-300,y-10,"1.Rs.10000   5.Rs.50000   9.Rs.90000");
outtextxy(x-300,y+15-10,"2.Rs.20000   6.Rs.60000  10.Rs.100000");
outtextxy(x-300,y+30-10,"3.Rs.30000   7.Rs.70000  11.Rs.110000");
setcolor(GREEN);
outtextxy(x-300,y+45-10,"4.Rs.40000   8.Rs.80000  12.Rs.120000");

setcolor(BLUE);
outtextxy(x-300,y+60+10,"enter 1-4 for answering ");
delay(150);
outtextxy(x-300,y+75+10,"enter 0 for 50-50 option ");
delay(150);
outtextxy(x-300,y+90+10,"enter 5 for withdraw ");
getch();
    closegraph();
}
void sound_p1()
{
    for(int g=0;g<2;g++)
    {
        sound(500);        delay(300);
        sound(400);        delay(180);
        sound(450);        delay(450);
        sound(350);        delay(180);
        sound(400);        delay(180);
        sound(350);        delay(180);
        sound(400);        delay(180);
    }
    nosound();
}
void sound_cong()
{
    for(int g=0;g<2;g++)
    {
        sound(350);        delay(300);
        sound(400);        delay(200);
        sound(450);        delay(400);
        sound(500);        delay(200);
        sound(350);        delay(180);
        sound(400);        delay(180);
        sound(350);        delay(180);
        sound(400);        delay(180);
    }
    nosound();
}

No comments: