#include #include #include int main() { int x, y, z, balance, invest, guess, outcome; balance = 100; srand(time(NULL)); printf("Let's start to play the game with 3 dices\n"); printf("Your balance = $100\n"); while(balance>0 && balance <1000) { do{ printf("How much do you invest? $"); scanf("%d", &invest); }while(invest > balance || invest % 10 != 0 || invest < 0); do{ printf("What is your expected outcome, big(1) or small(0)? "); scanf("%d", &guess); }while (guess!=0 && guess!=1); x = rand() % 6 + 1; y = rand() % 6 + 1; z = rand() % 6 + 1; printf("The points of the 3 dices are %d %d %d\n", x, y ,z); if ( x + y + z <=10 ) { outcome = 0; printf("It is small, "); } else { outcome = 1; printf("It is big, "); } if (guess == outcome) { printf("a correct guess\n"); balance = balance + invest; } else { printf("an incorrect guess\n"); balance = balance - invest; } printf("Your balance = $%d\n\n", balance); } return 0; }