Error in the code ?

,

what is the error in this code ?
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

Read this please.

1 Like

What am i supposed to do? Frame a question out of your code? Why don’t you put up a question, post your code and then ask the bug? Please read the link @betlista gave you.

2 Likes