Jump to content

Programming Challenge: Number Guessing Game (Jan 14, 2025)

Featured Replies

Posted

Create an interactive Number Guessing Game that allows the user to guess a randomly generated number within a specified range.


Basic Requirements:

  1. The program should randomly select a number between 1 and 100.

  2. Prompt the user to guess the number.

  3. Provide feedback:

    • "Too high" if the guess is higher than the target number.

    • "Too low" if the guess is lower than the target number.

    • "Correct!" when the guess is right.

  4. Keep track of the number of attempts and display it when the user guesses correctly.

Bonus Features:

  • Allow the user to set their own range (e.g., 1 to 1000).

  • Implement a hints system that gives additional clues, such as whether the number is even or odd.

  • Add an option to play again after the game ends.

Example Output:

Welcome to the Number Guessing Game!
I'm thinking of a number between 1 and 100.

Enter your guess: 50
Too high! Try again.

Enter your guess: 25
Too low! Try again.

Enter your guess: 33
Correct! You guessed it in 3 attempts.
  • Views 163
  • Created
  • Last Reply

Create an account or sign in to comment

Important Information

Terms of Use Privacy Policy Guidelines We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.