123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Number Game in C++.

--------------------------------------------------------------------------------

Description : This is a C++ program,it mainly uses the switch control statement.This simply uses the logic of the particular number game...try it

#include<iostream.h>
#include<conio.h>
void main()
{
int s,a,t,o,x=2,c,r,i;
char ch;
s=t=0,r=22,c=2;
clrscr();
cout<<" This is a computer Game.

########################

There are 22 balls on a table,you can take
either a
";
cout<<"maximum of 4 balls or a minimum of 1 at a time.If you take<BR>;
cout<<" the last ball from the table you will WIN other wise Computer
..<BR>;
cout<<"
Either You or Coputer can Take First ,Enter yr choice
I(you)/C(computer)<BR>;
cin>>ch;
if (ch=='I'|| ch=='i')
{
i=1,o=1;
s:
for (;i<17;i++)
{
cout<<"

You:";
cin>>a;
switch(a)
{
case 1:
r=r-a;
s=s+a;
cout<<"Remaining ="<<r;
break;

case 2:
s=s+a;
r=r-a;
cout<<"Remainig ="<<r;
if(i==1)
{ cout<<"

VIJOY:"<<o;
r=r-o;
s=s+o;
cout<<"
Remaining ="<<r;
i=2; goto s;
}
break;

case 3:
s=s+a;
r=r-a;
cout<<"Remainig ="<<r;
break;

case 4:
s=s+a;
r=r-a;
cout<<"Remaining ="<<r;
if(i==2)
{ cout<<"

VIJOY:"<<o;
r=r-o;
s=s+o;
cout<<"
Remaining ="<<r;
i=3;goto s;}

if(i==3)
{ cout<<"

VIJOY:"<<2;
r=r-2;
s=s+2;
cout<<"
Remaining ="<<r;
i=4;goto s;}
break;
default:
cout<<"Wrong Withdrawl......<BR>;
cout<<"Exitting...";goto e;
}

j:
if(s<c)
{
t=c-s;
s=s+t;
r=r-t;
if(t==5)
{cout<<"

Since I Have To WIN I Am Taking 5 Balls...";
cout<<"
VIJOY:"<<t;
cout<<"
Remainig ="<<r;
cout<<"

Anyway Congrats To You<BR>;
goto e;}
cout<<"

VIJOY:"<<t;
cout<<"
Remainig ="<<r;

if(r==0)
{cout<<"

You Lost The Game........!!!!
Think again....<BR>;
goto e;}

c=c+5;
i=5;
}
else
{ c=c+5;goto j;}
}
}
else
{
cout<<"
Coputer:"<<x;
r=r-x;
cout<<"
Remainig ="<<r;
s=s+x;
i=5;
goto s;
}
e:
getch();
clrscr();
cout<<"






This Game Is Created & Developed By Mr.VIJOY
JOSEPH<BR>;
cout<<"Contact: Tel(Res): 0478-2812600
e-mail:
vijoyjoseph@hotmail.com<BR>;
cout<<"Website: WWW.geocities.com/vijoyxxx<BR>;
for(i=1;i<20;i++)
cout<<"a";
getch();
}

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG