Title Number Game in C++. Author: Vijoy Joseph Visitor Submitted Source Code Author Email: vijoyjoseph@email.com 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 Hits: 3119 Since 25th November, 2003 Code: Select and Copy the Code #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.\n ########################\n\nThere are 22 balls on a table,you can take either a\n "; cout<<"maximum of 4 balls or a minimum of 1 at a time.If you take\n"; cout<<" the last ball from the table you will WIN other wise Computer ..\n"; cout<<"\nEither You or Coputer can Take First ,Enter yr choice I(you)/C(computer)\n"; cin>>ch; if (ch=='I'|| ch=='i') { i=1,o=1; s: for (;i<17;i++) { cout<<"\n\nYou:"; 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<<"\n\nVIJOY:"<<o; r=r-o; s=s+o; cout<<"\nRemaining ="<<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<<"\n\nVIJOY:"<<o; r=r-o; s=s+o; cout<<"\nRemaining ="<<r; i=3;goto s;} if(i==3) { cout<<"\n\nVIJOY:"<<2; r=r-2; s=s+2; cout<<"\nRemaining ="<<r; i=4;goto s;} break; default: cout<<"Wrong Withdrawl......\n"; cout<<"Exitting...";goto e; } j: if(s<c) { t=c-s; s=s+t; r=r-t; if(t==5) {cout<<"\n\nSince I Have To WIN I Am Taking 5 Balls..."; cout<<"\nVIJOY:"<<t; cout<<"\nRemainig ="<<r; cout<<"\n\nAnyway Congrats To You\n"; goto e;} cout<<"\n\nVIJOY:"<<t; cout<<"\nRemainig ="<<r; if(r==0) {cout<<"\n\nYou Lost The Game........!!!! \nThink again....\n"; goto e;} c=c+5; i=5; } else { c=c+5;goto j;} } } else { cout<<"\nCoputer:"<<x; r=r-x; cout<<"\nRemainig ="<<r; s=s+x; i=5; goto s; } e: getch(); clrscr(); cout<<"\n\n\n\n\n\n\nThis Game Is Created & Developed By Mr.VIJOY JOSEPH\n"; cout<<"Contact: Tel(Res): 0478-2812600\ne-mail: vijoyjoseph@hotmail.com\n"; cout<<"Website: WWW.geocities.com/vijoyxxx\n"; for(i=1;i<20;i++) cout<<"\a"; getch(); }