# Thread: Monopoly snippet can't find the problem

1. ## Monopoly snippet can't find the problem

Code:
```int dice; //total of 2 dices
int doublestatus = 1; //shows whether it is a double or not, default is 1 so user can start rolling

int dicerolling ()
{
srand (time(NULL));

int dice1;
int dice2;

dice1 = rand() %6;
dice1 = dice1 + 1;

dice2 = rand() %6;
dice2 = dice2 + 1;

printf("You rolled");
printf(" %d",dice1);
printf(" and ");
printf("%d. ",dice2);

if (dice1 == dice2)
{
printf("It's a double!");
doublestatus = 1;
}
else
doublestatus = 0;

printf("\nTotal is ");

dice=dice1+dice2;

printf("%d.\n",dice);

}

{
printf("\nMake a decision:\n");
printf("1 - Roll the dice\n");
printf("2 - Check balance\n");
printf("3 - Manage money\n");
printf("4 - Show current position\n");
printf("5 - End turn\n");
}

void menualt () //for when user rolls a double
{
printf("\nMake a decision:\n");
printf("Dice rolled\n");
printf("2 - Check balance\n");
printf("3 - Manage money\n");
printf("4 - Show current position\n");
printf("5 - End turn\n");
}

int main()

{

int cursor = 0; //user selection

int doublecount = 0; //counts the amount of double (if exceed 3 go to jail)

int pos = 0;

printf("Input: ");
scanf ("%d",&cursor);

while (cursor != 5)
{

if (cursor == 1) //rolling the dice, moving and 3 doubles go to jail
{
while (doublestatus == 1 && doublecount < 3)
{
dicerolling();
doublecount++;
pos = pos + dice;
printf ("You landed on ");
poscount (pos);

if (doublestatus == 1)
{
printf("Input: ");
scanf ("%d",&cursor);
}
else
{

while (cursor !=5) //special loop when user already rolled the dice and can not roll again
{

printf("Input: ");
scanf ("%d",&cursor);

if (cursor == 1)

else if (cursor == 2)
{ }

else if (cursor == 3)
{ }

else if (cursor == 4)
{

printf("You are at ");
poscount (pos);

}

else
{ }

}

}
if (doublecount == 3)
pos = 100; //special position when you are in jail to seperate from visitors
}
}

else if (cursor == 2)
{ }

else if (cursor == 3)
{ }

else if (cursor == 4)
{

printf("You are at ");
poscount (pos);

}
else
{ }
}
}```
poscount is a function that compare position and generate the name

what is broken is whenever user rolls a double and then hit 4 to check their position the dice rolls again even though it suppose to show their position
things work fine if they roll again after the double then check for position 2. > what is broken is whenever user rolls a double and then hit 4 to check their position the dice rolls again even though it suppose to show their position
Perhaps it's because of doublestatus == 1 and that you then miss out all the "special loop when user already rolled the dice" code. Popular pages Recent additions cursor, double, doublestatus, int, position 