Hello all,

I am basically trying to create a game where there are 32 marbles in a bag, there are 2 players, the objective is for the bag to be left with 1 marble. Each player has a choice to take out 1,2, or 3 marbles on each turn.

I have my program running okay, subtracting values from 32 until it reaches 1 however it does not stop at 1 it keeps going to down to negative numbers. I dont understand why this is because I have if statements in there. Can someone take a look?

This should be very simple...

Code:#include <stdio.h> int main() { int num_marbles1, num_marbles2, all_marbles=32; printf("There are 32 marbles remaining.\n\n"); while(all_marbles!=1){ printf("How many marbles would you like to take? ...Player 1\n"); scanf("%d", &num_marbles1); printf("There are %d marbles remaining\n\n", all_marbles=all_marbles-num_marbles1); printf("How many marbles would you like to take? ...Player 2\n"); scanf("%d", &num_marbles2); printf("There are %d marbles remaining.\n", all_marbles=all_marbles-num_marbles2); if (all_marbles-num_marbles1==1) { printf("\nPlayer 1 Wins.\n"); } else if (all_marbles-num_marbles2==1) { printf("\nPlayer 2 Wins.\n"); } } system ("PAUSE"); return 0; }