MOUSE POINTER IN C(USING GRAPHICS)


#include<dos.h>
#include<graphics.h>
#include<alloc.h>
#include<conio.h>
#include<stdio.h>
char *menu[]={“samosa”,”sambharwada”,”dahiwada”,”exit”};
union REGS i,o;
main()
{
int gd=DETECT,gm,choice=1,bill=0,width=0,i,count;
char **buffer;
initgraph(&gd,&gm,”c:\\tc\\bgi”);
if(initmouse()==0)
{
printf(“\n unable to initialise mouse…”);
exit();
}

count=sizeof(menu)/sizeof(char *);
settextstyle(TRIPLEX_FONT,0,3);
displaymenu(menu,count,100,100);

for(i=0;i<count;i++)
{
if(textwidth(menu[i])>width)
width=textwidth(menu[i]);
}
buffer=malloc(sizeof(menu));
savemenu(menu,buffer,width,count,100,100);

while(choice!=4)
{
choice=getresponse(menu,buffer,width,count,100,100);
gotoxy(50,15);
printf(“you selected%s”,menu[choice-1]);
}
displaymenu(char**menu,int count,int x1,int y1)
{
int i,h;
h=textheight(menu[0]);
for(i=0;i<count;i++)
{
outtexttxy(x1,y1+i*(h+5),menu[i]);
}
}

savemenu(char**menu,char**buffer,int width,int count,int x1,int y1)
{
int i,x2,yy1,yy2,area,h;
h=textheight(menu[0]);
for(i=0;i<count;i++)
{
x2=x1+width;
yy1=y1+i*(h+5);
yy2=y1+(i+1)*(h+5);
area=imagesize(x1,yy1,x2,yy2);
buffer[i]=malloc(area);
getimage(x1,yy1,x2,yy2,buffer[i]);
}
}

getresponse(char**menu,char**buffer,int width,int count,int x1,int y1)
{
int choice=1,prevchoice=0,x,y,x2,y2,button;
int in,i,h;
h=textheight(menu[0]);
y2=y1+count*(h+5);
x2=x1+width;
rectangle(x1-5,y1-5,x2+5,y2+5);

while(1)
{
getmousepos(&button,&x,&y);
if(x>=x1 &&x<=x2 && y>=y1 && y<=y2)
{
in=1;
for(i=1;i<=count;i++)
{
if(y<=y1+i*(h+5))
{
choice=i;
break;
}
}

if(prevchoice!=choice)
{
hidemouseptr();
highlight(buffer,choice,h,x1,y1);
if(prevchoice)
dehighlight(buffer,prevchoice,h,x1,y1);
prevchoice=choice;
showmouseptr();
}

if((button & 1)==1)
{

while((button & 1)==1)
getmousepos(&button,&x,&y);
if(x>=x1 && x<=x2 && y>=y1 && y<=y2)
return(choice);
}
}
else
{
if(in==1)
{
in=0;
prevchoice=0;
hidemouseptr();
dehighlight(buffer,choice,h,x1,y1);
showmouseptr();
}
}
}
}

highlight(char**menu,char**buffer,int width,int count,int x1,int y1)
{
putimage(x1,y1+(ch-1)*(h+5),buffer[ch-1],NOT_PUT);
}

dehighlight(char**menu,char**buffer,int width,int count,int x1,int y1)
{
putimage(x1,y1+(ch-1)*(h+5),buffer[ch-1],COPY_PUT);
}

initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}

showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}

hidemouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
}

getmousepos(int*button,int*x,int*y)
{
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
}
}

CONSOLE BASED TIC TAC TOE GAME FOR TWO PLAYERS


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int Board();
int PlayerX();
int PlayerO();
int Player_win();
int check();
int win=0,wrong_X=0,wrong_O=0,chk=0;

char name_X[30];
char name_O[30];
int pos_for_X[3][3];
int pos_for_O[3][3];
int pos_marked[3][3];

main()
{
int i,ch,j;
char ans;

printf(“\n\t\t\t\tTIC TAC TOE”);
printf(“\n\t\t\t\t”);
for(i=1;i<=11;i++)
{

printf(“*”);
}
do
{

printf(“\n\t\t\t\tTIC TAC TOE”);
printf(“\n\t\t\t\t”);
for(i=1;i<=11;i++)
{

printf(“*”);
}
printf(“\n1.Start The Game”);
printf(“\n2.Quit The Game”);
printf(“\nEnter your choice(1-2) : “);
scanf(“%d”,&ch);
switch(ch)
{
case 1:
chk=0;
win=0;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
pos_for_X[i][j]=0;
pos_for_O[i][j]=0;
pos_marked[i][j]=0;
}
}
printf(“\n\n”);

printf(“\nEnter the name of the player playing for \’X\’: “);
fflush(stdin);
gets(name_X);
printf(“\nEnter the name of the player playing for \’O\’: “);
fflush(stdin);
gets(name_O);
Board();
for(;;)
{
if(win==1)
break;
check();
if(chk==9)
{
printf(“\n\t\t\tMATCH DRAWS!!”);
printf(“\nPress any key….”);
break;
}
else
chk=0;
printf(“\nTURN FOR %s:”,name_X);
PlayerX();
do
{
if(wrong_X!=1)
break;
wrong_X=0;
printf(“\nTURN FOR %s:”,name_X);
PlayerX();
}while(wrong_X==1);
check();
if(chk==9)
{
printf(“\n\t\t\tMATCH DRAWS”);
printf(“\nPress any key….”);
break;
}
else
chk=0;
printf(“\nTURN FOR %s:”,name_O);
PlayerO();
do
{
if(wrong_O!=1)
break;
wrong_O=0;
printf(“\nTURN FOR %s:”,name_O);
PlayerO();
}while(wrong_O==1);

}
Board();
if(win!=1)
{
printf(“\n\t\t\tMATCH DRAWS!!”);
printf(“\nPress any key…….”);
}
getch();
break;
case 2:
printf(“\n\n\n\t\t\tThank You For Playing The Game.”);
printf(“\n\t\t\t###############################”);
getch();
exit(1);
break;
}
printf(“\nWant To Play(Y/N) ? “);
fflush(stdin);
scanf(“%c”,&ans);
}while(ans==’y’ || ans==’Y’);
getch();
}

int Board()
{
int i,j;

printf(“\n\t\t\t\tTIC TAC TOE BOARD”);
printf(“\n\t\t\t\t*****************”);
printf(“\n\n\n”);
printf(“\n\t\t\t    1\t      2\t        3”);
for(i=1;i<=3;i++)
{
printf(“\n \t\t\t _____________________________”);
printf(“\n \t\t\tº\t  º\t   º\t     º”);
printf(“\n\t\t%d\t”,i);
for(j=1;j<=3;j++)
{

if(pos_for_X[i][j]==1)
{
printf(”    X”);
printf(”     “);
}
else if(pos_for_O[i][j]==1)
{
printf(”    O”);
printf(”     “);
}
else
{
printf(”          “);
continue;
}
}
printf(“\n\t\t\tº\t  º\t   º\t     º”);
}
printf(“\n\t\t\t——————————“);
Player_win();
}

int PlayerX()
{
int row,col;
if(win==1)
return win;
printf(“\nEnter the row no. : “);
fflush(stdin);
scanf(“%d”,&row);
printf(“Enter the column no. : “);
fflush(stdin);
scanf(“%d”,&col);
if(pos_marked[row][col]==1 || row<1 || row>3 || col<1 || col>3)
{
printf(“\nWRONG POSITION!! Press any key…..”);
wrong_X=1;
getch();
Board();
}
else
{
pos_for_X[row][col]=1;
pos_marked[row][col]=1;
Board();
}
}
int PlayerO()
{
int row,col;
if(win==1)
return win;
printf(“\nEnter the row no. : “);
scanf(“%d”,&row);
printf(“Enter the column no. : “);
scanf(“%d”,&col);
if(pos_marked[row][col]==1 || row<1 || row>3 || col<1 || col>3)
{
printf(“\nWRONG POSITION!! Press any key….”);
wrong_O=1;
getch();
Board();
}
else
{
pos_for_O[row][col]=1;
pos_marked[row][col]=1;
Board();
}
}
int Player_win()
{
int i;
for(i=1;i<=3;i++)
{
if(pos_for_X[i][1]==1 && pos_for_X[i][2]==1 && pos_for_X[i][3]==1)
{
win=1;
printf(“\n\nRESULT: %s wins!!”,name_X);
printf(“\nPress any key…………”);
return win;
}
}
for(i=1;i<=3;i++)
{
if(pos_for_X[1][i]==1 && pos_for_X[2][i]==1 && pos_for_X[3][i]==1)
{
win=1;
printf(“\n\nRESULT: %s wins!!”,name_X);
printf(“\nPress any key…………”);
return win;
}
}
if(pos_for_X[1][1]==1 && pos_for_X[2][2]==1 && pos_for_X[3][3]==1)
{
win=1;
printf(“\n\nRESULTL: %s wins!!”,name_X);
printf(“\nPress any key……”);
return win;
}
else if(pos_for_X[1][3]==1 && pos_for_X[2][2]==1 &&pos_for_X[3][1]==1)
{
        win=1;
printf(“\n\nRESULT: %s wins!!”,name_X);
                printf(“\nPress any key…..”);
return win;
}

        for(i=1;i<=3;i++)
{
if(pos_for_O[i][1]==1 && pos_for_O[i][2]==1 && pos_for_O[i][3]==1)
{
win=1;
printf(“\n\nRESULT: %s wins!!”,name_O);
                        printf(“\nPress any key…..”);
return win;
}
}
for(i=1;i<=3;i++)
{
if(pos_for_O[1][i]==1 && pos_for_O[2][i]==1 && pos_for_O[3][i]==1)
{
win=1;
printf(“\n\nRESULT: %s wins!!”,name_O);
            printf(“\nPress any key…..”);
return win;
}
}
if(pos_for_O[1][1]==1 && pos_for_O[2][2]==1 && pos_for_O[3][3]==1)
{
win=1;
printf(“\n\nRESULT: %s wins!!”,name_O);
printf(“\nPress any key…..”);
return win;
}
else if(pos_for_O[1][3]==1 && pos_for_O[2][2]==1 &&
 pos_for_O[3][1]==1)
{
        win=1;
printf(“\n\nRESULT: %s wins!!”,name_O);
                printf(“\nPress any key…..”);
return win;
}
}
int check()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
if(pos_marked[i][j]==1)
chk++;
else
continue;
}
}
}

SNAKE AND LADDER GAME IN C++


//***************************************************************
// Source Code 
//****************************************************************
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
void draw_line(int n,char ch);
void board();
void gamescore(char name1[],char name2[],int p1, int p2);
void play_dice(int &score);
void main()
{
int player1=0,player2=0,lastposition;
char player1name[80],player2name[80];
clrscr();
randomize();
draw_line(50,’=’);
cout<<“\n\n\n\n\t\tSNAKE LADDER GAME\n\n\n\n”;
draw_line(50,’=’);
cout<<“\n\n\nEnter Name of player 1 :”;
gets(player1name);
cout<<“\n\n\Enter Name of player 2 :”;
gets(player2name);
while(player1<=100 && player2<=100)
{
board();
gamescore(player1name,player2name,player1,player2);
cout<<“\n\n—>” <<player1name<<” Now your Turn >> Press any key to play “;
getch();
lastposition=player1;
play_dice(player1);
if(player1<lastposition)
cout<<“\n\aOops!! Snake found !! You are at postion “<<player1<<“\n”;
else if(player1>lastposition+6)
cout<<“\nGreat!! you got a ladder !! You are at position “<<player1;
cout<<“\n\n—>”<<player2name<<” Now your Turn >> Press any key to play “;
getch();
lastposition=player2;
play_dice(player2);
if(player2<lastposition)
cout<<“\n\n\aOops!! Snake found !! You are at position “<<player2<<“\n”;
else if(player2>lastposition+6)
cout<<“\n\nGreat!! you got a ladder !! You are at position “<<player2<<“\n”;
getch();
}
clrscr();
cout<<“\n\n\n”;
draw_line(50,’+’);
cout<<“\n\n\t\tRESULT\n\n”;
draw_line(50,’+’);
cout<<endl;
gamescore(player1name,player2name,player1,player2);
cout<<“\n\n\n”;
if(player1>=player2)
cout<<player1name<<” !! You are the winner of the game\n\n”;
else
cout<<player2name<<” !! You are the winner of the game\n\n”;
draw_line(50,’+’);
getch();
}
void draw_line(int n,char ch)
{
for(int i=0;i<n;i++)
cout<<ch;
}
void board()
{
clrscr();
cout<<“\n\n”;
draw_line(50,’-‘);
cout<<“\n\t\tSNAKE AT POSITION\n”;
draw_line(50,’-‘);
cout<<“\n\tFrom 98 to 28 \n\tFrom 95 to 24\n\tFrom 92 to 51\n\tFrom 83 to 19\n\tFrom 73 to 1\n\tFrom 69 to 33\n\tFrom 64 to 36\n\tFrom 59 to 17\n\tFrom 55 to 7\n\tFrom 52 to 11\n\tFrom 48 to 9\n\tFrom 46 to 5\n\tFrom 44 to 22\n\n”;
draw_line(50,’-‘);
cout<<“\n\t\t LADDER AT POSITION\n”;
draw_line(50,’-‘);
cout<<“\n\tFrom 8 to 26\n\tFrom 21 to 82\n\tFrom 43 to 77\n\tFrom 50 to 91\n\tFrom 62 to 96\n\tFrom 66 to 87\n\tFrom 80 to 100\n”;
draw_line(50,’-‘);
cout<<endl;
}
void gamescore(char name1[],char name2[],int p1, int p2)
{
cout<<“\n”;
draw_line(50,’~’);
cout<<“\n\t\tGAME STATUS\n”;
draw_line(50,’~’);
cout<<“\n\t—>”<<name1<<” is at position “<<p1<<endl;
cout<<“\t—>”<<name2<<” is at position “<<p2<<endl;
draw_line(50,’_’);
cout<<endl;
}
void play_dice(int &score)
{
int dice;
dice=random(6)+1;
cout<<“\nYou got “<<dice<<” Point !! “;
score=score+dice;
cout<<“Now you are at position “<<score;
switch(score)
{
case 98 :score=28;break;
case 95 :score=24;break;
case 92 :score=51;break;
case 83 :score=19;break;
case 73 :score=1;break;
case 69 :score=33;break;
case 64 :score=36;break;
case 59 :score=17;break;
case 55 :score=7;break;
case 52 :score=11;break;
case 48 :score=9;break;
case 46 :score=5;break;
case 44 :score=22;break;
case 8 :score=26;break;
case 21 :score=82;break;
case 43 :score=77;break;
case 50 :score=91;break;
case 54 :score=93;break;
case 62 :score=96;break;
case 66 :score=87;break;
case 80 :score=100;
}
}
//***************************************************************
// END OF PROJECT
//***************************************************************

CASINO GAME PROJECT IN C++


//***************************************************************
// Source Code 
//****************************************************************
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
void draw_line(int n,char ch);
void rules();
void main()
{
int balanceamt,amt,no,dice;
char playername[80],ch;
clrscr();
draw_line(60,’=’);
cout<<“\n\n\n\n\t\tCASINO GAME\n\n\n\n”;
draw_line(60,’=’);
cout<<“\n\n\nEnter Your Name :”;
gets(playername);
cout<<“\n\n\Enter Deposit amount to play game :”;
cin>>balanceamt;
do
{
clrscr();
rules();
cout<<“\n\nYour current balance is Rs.”<<balanceamt;
do
{
cout<<“\n\n”<<playername<<” enter money to bet”;
cin>>amt;
if(amt>balanceamt)
cout<<“Your betting amount is more than your current balance\n\nRe-enter data\n “;
else
break;
}while(1);
do
{
cout<<“Enter your lucky number to bet between 1 to 12 :”;
cin>>no;
if(no<=0||no>12)
cout<<“Please check the number!! should be between 1 to 12\n\nRe-enter data\n “;
else
break;
}while(1);
randomize();
dice=random(12)+1;
if(dice==no)
{
cout<<“\n\nGood Luck!! You won Rs.”<<amt*10;
balanceamt=balanceamt+amt*10;
}
else
{
cout<<“Bad Luck this time !! You lose Rs.”<<amt;
balanceamt=balanceamt-amt;
}
cout<<“\n\nThe winning number was : “<<dice;
cout<<“\n\n\t”<<playername<<” You have Rs. “<<balanceamt<<endl;
cout<<“\n\n–>Do you want to play (y/n)? “;
cin>>ch;
}while(ch==’Y’|| ch==’y’);
clrscr();
cout<<“\n\n\n”;
draw_line(70,’+’);
cout<<“\n\n\t\THANKS FOR COME TO CASINO YOUR BALANCE AMOUNT IS RS.”<<balanceamt<<“\n\n”;
draw_line(70,’+’);
cout<<“\n\nGame developed by ANIKET RAJPUT\n”;
draw_line(70,’+’);
getch();
}
void draw_line(int n,char ch)
{
for(int i=0;i<n;i++)
cout<<ch;
}
void rules()
{
clrscr();
cout<<“\n\n”;
draw_line(60,’-‘);
cout<<“\n\t\tRULES OF THE GAME\n”;
draw_line(60,’-‘);
cout<<“\n\t1. Choose any number between 1 to 12\n\t2. If you win you will get 10 times of money you bet\n\t3. If you bet on wrong number you will lose your betting amount\n\n”;
draw_line(60,’-‘);
cout<<endl;
}

//***************************************************************
// END OF PROJECT
//***************************************************************

The Mind Reader Game


/*NOTE THAT THE GAME WORKS ONLY IN TURBO C ENVIRONMENT IF YOU WANT TO RUN THE PROGRAM IN ANY OTHER ENVIRONMENT THEN THEN YOU HAVE TO DOWNLOAD THE WINBGI SOFTWARE AND ALSO FOLLOW THE INSTRUUCTION ONLINE */
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
void First_Card(void);
void Second_Card(void);
void Third_Card(void);
void Fourth_Card(void);
void Fifth_Card(void);
void Sixth_Card(void);
void Analyze(void);
int Check(void);
int main()
{
      clrscr();
      int ans=0,in=0;
   _setcursortype(_NOCURSOR);
   First_Card();
     in=Check(); if (in==0) ans+=1;
   Second_Card();
     in=Check(); if (in==0) ans+=2;
   Third_Card();
     in=Check(); if (in==0) ans+=4;
   Fourth_Card();
     in=Check(); if (in==0) ans+=8;
   Fifth_Card();
     in=Check(); if (in==0) ans+=16;
   Sixth_Card();
     in=Check(); if (in==0) ans+=32;
     textcolor(WHITE);textbackground(BLACK);
     clrscr(); Analyze();     clrscr();
   if(ans>60) {gotoxy(20,12);printf(“You Entered Incorrect Information.”);}
   else
   {
       gotoxy(28,13);printf(“Your No Is : \”%d\””,ans);}
   gotoxy(20,14);printf(“Thanks For Using This Program… “);
   gotoxy(30,22);printf(“Made By : “);
   gotoxy(37,23);printf(“ANIMESH SHAW”);getch();return 0;
}
void First_Card(void)
{
gotoxy(25,6);  printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”);
gotoxy(25,7);  printf(“º  C O M P U T E R   G A M E  º”);
gotoxy(25,8);  printf(“ÌÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍ͹”);
gotoxy(25,9);  printf(“º 1  º 3  º 5  º 7  º 9  º 11 º”);
gotoxy(25,10); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,11); printf(“º 13 º 15 º 17 º 19 º 21 º 23 º”);
gotoxy(25,12); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,13); printf(“º 25 º 27 º 29 º 31 º 33 º 35 º”);
gotoxy(25,14); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,15); printf(“º 37 º 39 º 41 º 43 º 45 º 47 º”);
gotoxy(25,16); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,17); printf(“º 49 º 51 º 53 º 55 º 57 º 59 º”);
gotoxy(25,18); printf(“ÈÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍͼ”);
}
void Second_Card(void)
{
gotoxy(25,6);  printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”);
gotoxy(25,7);  printf(“º  C O M P U T E R   G A M E  º”);
gotoxy(25,8);  printf(“ÌÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍ͹”);
gotoxy(25,9);  printf(“º 2  º 3  º 6  º 7  º 10 º 11 º”);
gotoxy(25,10); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,11); printf(“º 14 º 15 º 18 º 19 º 22 º 23 º”);
gotoxy(25,12); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,13); printf(“º 25 º 27 º 30 º 31 º 34 º 35 º”);
gotoxy(25,14); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,15); printf(“º 38 º 39 º 42 º 43 º 46 º 47 º”);
gotoxy(25,16); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,17); printf(“º 50 º 51 º 54 º 55 º 58 º 59 º”);
gotoxy(25,18); printf(“ÈÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍͼ”);
}
void Third_Card(void)
{
gotoxy(25,6);  printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”);
gotoxy(25,7);  printf(“º  C O M P U T E R   G A M E  º”);
gotoxy(25,8);  printf(“ÌÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍ͹”);
gotoxy(25,9);  printf(“º 4  º 5  º 6  º 7  º 12 º 13 º”);
gotoxy(25,10); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,11); printf(“º 14 º 15 º 20 º 21 º 22 º 23 º”);
gotoxy(25,12); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,13); printf(“º 28 º 29 º 30 º 31 º 36 º 37 º”);
gotoxy(25,14); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,15); printf(“º 38 º 39 º 44 º 45 º 46 º 47 º”);
gotoxy(25,16); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,17); printf(“º 52 º 53 º 54 º 55 º 60 º 60 º”);
gotoxy(25,18); printf(“ÈÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍͼ”);
}
void Fourth_Card(void)
{
gotoxy(25,6);  printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”);
gotoxy(25,7);  printf(“º  C O M P U T E R   G A M E  º”);
gotoxy(25,8);  printf(“ÌÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍ͹”);
gotoxy(25,9);  printf(“º 8  º 9  º 10 º 11 º 12 º 13 º”);
gotoxy(25,10); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,11); printf(“º 14 º 15 º 24 º 25 º 26 º 27 º”);
gotoxy(25,12); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,13); printf(“º 28 º 29 º 30 º 31 º 40 º 41 º”);
gotoxy(25,14); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,15); printf(“º 42 º 43 º 44 º 45 º 46 º 47 º”);
gotoxy(25,16); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,17); printf(“º 56 º 57 º 58 º 59 º 60 º 60 º”);
gotoxy(25,18); printf(“ÈÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍͼ”);
}
void Fifth_Card(void)
{
gotoxy(25,6);  printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”);
gotoxy(25,7);  printf(“º  C O M P U T E R   G A M E  º”);
gotoxy(25,8);  printf(“ÌÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍÍËÍÍÍ͹”);
gotoxy(25,9);  printf(“º 16 º 17 º 18 º 19 º 20 º 21 º”);
gotoxy(25,10); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,11); printf(“º 22 º 23 º 24 º 25 º 26 º 27 º”);
gotoxy(25,12); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,13); printf(“º 28 º 29 º 30 º 31 º 48 º 49 º”);
gotoxy(25,14); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,15); printf(“º 50 º 51 º 52 º 53 º 54 º 55 º”);
gotoxy(25,16); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,17); printf(“º 56 º 57 º 58 º 59 º 60 º 60 º”);
gotoxy(25,18); printf(“ÈÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍͼ”);
}
void Sixth_Card(void)
{
gotoxy(25,6);  printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»52 º 53 º 54 º 55 º”);
gotoxy(25,16); printf(“ÌÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍÍÎÍÍÍ͹”);
gotoxy(25,17); printf(“º 56 º 57 º 58 º 59 º 60 º 60 º”);
gotoxy(25,18); printf(“ÈÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍÍÊÍÍÍͼ”);
}
 int Check(void)
{
  int loop,key,index=0;
  char *menu[]={” Yes “,” No “};
  textcolor(WHITE);
  textbackground(CYAN);
  while(1)
  { for (loop=0;loop<2;loop++)
    { if (loop==index)
textbackground(YELLOW);
      else
textbackground(CYAN);
      gotoxy(33+loop*10,20);cprintf(“%s”,menu[loop]);
    }
    key=getch();
    switch(key)
    { case 75:
index–;if (index<0) index=1;break;
      case 77:
index++;if (index>1) index=0;break;
      case 13: return index;
    }
  }
}
void Analyze(void)
{
 gotoxy(30,10); printf(“Analyzing Result…”);
 gotoxy(25,11); printf(“ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”);
 gotoxy(25,12); printf(“º °°°°°°°°°°°°°°°°°°°°°°°°°°° º”);
 gotoxy(25,13); printf(“ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ”);
 for(int a=27;a<=53;a++)
 { delay(100);
   gotoxy(a,12);printf(“%c”,219);
 }
}

HIGH LOW GAME


     /* HIGH/LOW GAME */
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
/*
This program plays a simple game.The computer picks a random number
from
0 to 100, and the user tries to guess the number.
*/
const int totchan=7;
main()
{
 int number;        //the computer’s random number
 int guess;         //the user’s guess
 int chances=0,score=0,chanscor;        //chanscor stores score for 1 successful chance.
 char ans;
 do
 {
   chances=score=0;
   cout<<“\nWelcome to the High/Low game.”;
   cout<<“\nI will pick a random number from 0 to 100.”;
   cout<<“\nYou must try to guess the number.”;
 
   number=(int)(rand()%100);
   chanscor=100/totchan;        //score for each successful chance
   do
   {
     cout<<“\nWhat is your guess? (0 to 100) “;
     cin>>guess;
     if((guess<0)||(guess>100))
     {
cout<<“Sorry, but your guess “<<guess<<“must be from 0 to 100.”;
     }
     else if(guess < number)
     {
cout<<guess<<” is low.Try a higher number.”;
     }
     else if(guess > number)
     {
cout<<guess<<” is high.Try a lower number.”;
     }
     else //if correct number is guessed
     { //number is correct, and the “do” loop will end below
cout<<guess<<” is correct. Congratulations!”;
score=chanscor*(totchan-chances);   //score calculated for number of chances left
cout<<“Your score is “<<score<<endl;
        break;
     }
     chances++;
     if(guess!=number)
cout<<“Now you have “<<totchan-chances<<“chances left.”<<endl;
     if(chances==totchan)
{ cout<<“Only “<<totchan<<“chances are allowed.Better luck next time”;
  cout<<“\nThe actual number was “<<number<<endl;
  break;
}
     }while (guess!=number);
     cout<<“Thank you for playing High/Low!”;
     cout<<“Want to play it again? (y/n)…”;
     cin>>ans;
   }while(ans==’y’ || ans==’Y’);
 }

NUMBER MAGIC GAME


#include<stdio.h>
#include<conio.h>
int generate(void);
int fun(int);
main()
{
 int i,a,r;

 printf(“\n\nANIMESH Welcomes You!\n IN THE JARGON OF A NUMBER..”);
 printf(“\nPress any key to continue….”);
 getch();
 printf(“\n\nJust think a number between 1 to 63 in your mind”);
 printf(“\nThink on one”);
 printf(“\nDo not enter that number”);
 printf(“\n\nI will find that number on your mind….”);
 printf(“\n\nPress any key to continue…”);
 getch();
 printf(“\nBy Just answering few questions….”);
 printf(“\n\nIf your number is present in the numbers”);
 printf(“\n\nshown on your screen,Then press P and if not present”);
 printf(“\n\n then press N”);
 printf(“But please be honest while entering the answer…”);
 printf(“\n\nPress any key to continue…”);
 getch();
 r=generate();
 if(r==0)
 {
  printf(“\nYou didn’t think of any number between 1 to 63”);
  printf(“\nSo try again…”);
 }
 else
 {
 printf(“\nYour number is %d”,r);
 printf(“\nSurprised! But friends it is not a magic,”);
 printf(“\nit just involves some mathematical computation….”);
 printf(“\nso guys just try to find out the method.”);
 printf(“\nThank You!”);
 printf(“\nProgrammed By:\n\t\tAnimesh shaw”);
 }
 getch();
}
int generate()
{
 int a,i,j,f,num[6],n,r=0;
 char ch[6];
 for(j=0;j<=5;j++)
 {
  f=fun(j);
  for(i=1;i<=63;i++)
  {
   f=fun(j);
   printf(” %d”,f);
   a=i & f;
   if(a==f)
   printf(” %d”,i);
  }
  printf(“\n\n  Let me remind you if the number is present then”);
  printf(“\n press P otherwise press N”);
  printf(“\nEnter your answer: “);
  ch[j]=getche();
  printf(“\nPress any key to continue….”);
  if(ch[j]==’p’ || ch[j]==’P’)
  {
   num[j]=1;
   n=fun(j);
   r=r+n;
  }
  else
  num[j]=0;
  getch();
 }
 for(j=5;j>=0;j–)
 {
 printf(” %d”,num[j]);
 if(ch[j]==’p’ || ch[j]==’P’)
 num[j]=1;
 else
 num[j]=0;
 }
 printf(” %d”,r);
 return r;
}
int fun(int j)
{
 if(j==0)
 return 1;
 else
 return (2*fun(j-1));
}