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