// =============================================== // CHALLENGE 1: NUMBER GUESSING GAME // =============================================== // Create a game where the computer picks a random number (1-100) // and the player has to guess it. Give hints like "too high" or "too low" // Track the number of attempts and let them play again. // // Skills practiced: loops, conditionals, random numbers, input/output // // Your implementation here: #include #include #include // Starter code - you can modify or start from scratch int main() { int randomNum = 1; int playerInput = 0; srand(time(0)); while (randomNum != playerInput) { std::string continueGame = "yes"; int randomNum = rand() % 101; std::cout << "Your Random number has been generated (1-100) \n"; while (continueGame == "yes") { std::cout << "Enter your guess: "; std::cin >> playerInput; std::cout << "\n"; if (playerInput > randomNum) { std::cout << "Your guess is too high\n"; continue; } else if (playerInput < randomNum) { std::cout << "Your guess is too low\n"; continue; } else { std::cout << "Wow! Your did it!!!\n"; std::cout << "Do you want to continue?: "; std::cin >> continueGame; std::cout << "\n"; } } } // TODO: Implement the guessing game // Hints: // - Use std::random_device and std::mt19937 for random numbers // - Use a while loop for the game loop // - Use another loop for multiple rounds // - Keep track of attempts return 0; }