GETNUM GAME multiplayer contest

/Make this game a multiplayer game , in which 3 and 4 users can also play this game.
1> Player has to select a target number and range.
2> Game can be started with the numbers starting from 1 to the range selected.
3> next player can enter the corresponding numbers.
Like if the range is 2 and player 1 entered 1 then player 2 can enter 2 or 3 and if player 2 then entered 3 after that player 1 has the option two enter any number from the next two consicutive numbers
Like this the player who will enter the target number will win!
/

#include< stdio.h>
#include< conio.h>
#include< iostream.h>
#include< process.h>

void home();
void intro();
void range();
void start2();
void start3();

void main()

{
clrscr();

 home();

getch();
}

void home()
{
char opt;

clrscr();

printf("********************************************************************************");

printf(" GETNUM GAME ā€œ);
printf(ā€œ");
printf("\n Introduction [I]\n");
printf(" PLAY [P]");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("
ā€);
printf(ā€ EXIT [X]\n");
printf("********************************************************************************");

scanf("%c",&opt);

if(opt==ā€˜Iā€™ || opt==ā€˜iā€™)
intro();

else if(opt=='P' || opt=='p')

range();

else if(opt==ā€˜Xā€™ || opt==ā€˜xā€™)
exit(0);

else
home();

}

void intro()
{
printf(ā€œ");
printf(" Introduction ");
printf("
ā€);
printf("\n\n1> Player has to select a target number and range.\n"");
printf(ā€œ2> Game can be started with the numbers starting from 1 to the range selected.\nā€);
printf(ā€œ3> next player can enter the corresponding numbers.\nā€);
printf("\n\nLike if the range is 2 and player 1 entered 1 then player 2 can enter 2 or 3 and if player 2 then entered 3 after that player 1 has the option two enter any number from the next two consicutive numbers ā€œ);
printf(ā€\n\n Like this the player who will enter the target number will win");
}

void range()
{
char opt;

clrscr();

printf("********************************************************************************");
printf("                                  NEW  GAME                                   \n");
printf("********************************************************************************");
printf("\n\n\nSelect The Range [2/3]\n");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("********************************************************************************");
printf(" Home [H]                                                              Exit[X]\n");
printf("********************************************************************************");

scanf("%c",&opt);

if( opt=='2' )
 start2();

else if( opt=='H' || opt=='h')
 home();

else if( opt=='3' )
 start3();

else if( opt=='X' || opt=='x')
 exit(0);

else
 range();

}

void start2()
{
try: int i,a=0,b=0,rev=0,n;
char opt;

	clrscr();

printf("Enter the target number.\n");
scanf("%d",&n);

for(i=1;;i++)
{
	p1: printf("Player 1 enter the number.\n");
	scanf("%d",&rev);

	 if(rev<=n && rev<b+3 && rev>b)
		a=rev;

	 else if(rev>n)
	 { printf("Number greater than the target number %d is not allowed.\n\n",n);
		 goto p1;
	 }

	 else if( rev<=b && i>1 )
			{  printf("Player 1 can enter number greater than %d \n",b);
		 goto p1;
	 }

	 else if( rev>=(b+3) && i>1 )
	 {  printf("Player 1 can enter number less than %d \n",b);
			goto p1;
	 }

	 else if(i==1 && rev<=b || rev>=(b+3))
	 {  printf("Player 1 can enter 1 and 2 only.\n");
			goto p1;
	 }

	if(a==n)
		break;

 p2: printf("Player 2 enter the number.\n");
 scanf("%d",&rev);

		 if(rev<=n && rev>a && rev<a+3)
		 b=rev;

		 else if(rev>n)
		 { printf("Number greater than the target number %d is not allowed.\n\n",n);
			 goto p2;
		 }

		 else if(rev<=a )
		 { printf("Player 2 can enter number greater than %d \n",a);
			 goto p2;
		 }

			else if( rev>=(a+3) )
		 { printf("Player 2 can enter number less than %d \n",a+3);
			 goto p2;
		 }

		 if(b==n)
			break;
}

printf("********************************************************************************");
printf("                                     You Win!                                 \n");
printf("********************************************************************************");
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("********************************************************************************");
printf("Try Again [T]                      Home [H]                             Exit [X]");
printf("********************************************************************************");
r2:	scanf("%c",&opt);

if(opt=='T' || opt=='t')
	goto try;

else if(opt=='H' || opt=='h')
	home();

else if (opt=='X' || opt=='x')
 exit(0);

else
goto r2;

getch();

}

void start3()
{
try: int i,a=0,b=0,rev=0,n;
char opt;

clrscr();

printf("Enter the target number.\n");
scanf("%d",&n);

for(i=1;;i++)
{
	p1: printf("Player 1 enter the number.\n");
	scanf("%d",&rev);


	 if(rev<=n && rev<b+4 && rev>b)
		a=rev;

	 else if( rev>n )
	 { printf("Number greater than the target number %d is not allowed.\n\n",n);
		 goto p1;
	 }

	 else if(rev<=b || rev>=(b+4))
	 { printf("Player 1 can enter only %d or %d or %d.\n",b+1,b+2,b+3);
		 goto p1;
	 }

	if(a==n)
		break;

 p2: printf("Player 2 enter the number.\n");
 scanf("%d",&rev);

		 if(rev<=n && rev>a && rev<(a+4))
		 b=rev;

		 else if( rev>n )
		 { printf("Number greater than the target number %d is not allowed.\n\n",a+1,a+2,a+3);
			 goto p2;
		 }

		 else if( rev<=a || rev>=(a+4))
		 { printf("Player 2 can enter only %d or %d or %d.\n",a+1,a+2,a+3);
			goto p2;
		 }

	 if(b==n)
		break;

}
printf("********************************************************************************");
printf("                                     You Win!                                 \n");
printf("********************************************************************************");
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("********************************************************************************");
printf("Try Again [T]                      Home [H]                             Exit [X]");
printf("********************************************************************************");
r3:	scanf("%c",&opt);

if(opt=='T' || opt=='t')
	goto try;

else if(opt=='H' || opt=='h')
	home();

else if (opt=='X' || opt=='x')
 exit(0);

else
goto r3;

getch();

}

1 Like