0% found this document useful (0 votes)
158 views11 pages

Number Guessing Game

Number guessing game in c++ references notes

Uploaded by

wilfredjustin4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views11 pages

Number Guessing Game

Number guessing game in c++ references notes

Uploaded by

wilfredjustin4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

07

1 3 GAME EDITION

NUMBER
GUESSING
GAME
ABSTRACT
The Number Guessing Game is a simple, interactive
console-based C++ application designed to enhance
understanding of fundamental programming concepts such
as loops, conditionals, and random number generation. The
game challenges the player to guess a randomly generated
number within a specified range, providing hints if the
guess is too high or too low. The objective is to guess the
correct number in the fewest attempts possible. This project
serves as an introductory exercise for beginners to grasp
the basics of programming logic, user interaction, and
program flow control in C++.
The Number Guessing Game project is a small-scale
console application developed in C++ that offers a
fun and engaging way for users to interact with the
program. The game generates a random number
2 within a predefined range (e.g., 1 to 100), and the

1 player is prompted to guess the number. The


program provides feedback on whether the player's
guess is too high, too low, or correct, guiding the
PROJEC player toward the correct answer. The game
T
DESCR continues until the player successfully guesses the
IPTION number.

This project is ideal for beginners who are learning


C++ as it covers essential concepts such as:
-Random number generation
-Loops and conditionals
- User input/output handling
- Basic program structure
1 2 3

Easy level: Medium level: Difficult level:


10 chance 7 chance 5 chance

1 2 3
MODULES
1.Random Number Generation Module

Purpose: To generate a random number that the player


needs to guess.
Functions:
generateRandomNumber(int min, int max): Returns a
random number between specific minimum and maximum
value
2.PLAYER INTERACTION MODULE
PURPOSE: TO HANDLE USER INPUT AND PROVIDE FEEDBACK
BASED ON THE PLAYER’S GUESSES
FUNCTIONS:
GETPLAYERGUESS(): PROMPTS THE PLAYER TO ENTER THEIR
GUESS AND RETURNS THE ENTERED NUMBER.
PROVIDEFEEDBACK(INT GUESS, INT TARGET): COMPARES THE
PLAYER'S GUESS WITH THE TARGET NUMBER AND PROVIDES
FEEDBACK (E.G., TOO HIGH, TOO LOW)
3.GAME LOGIC MODULE

PURPOSE: TO MANAGE THE CORE GAME LOGIC, INCLUDING


TRACKING THE NUMBER OF ATTEMPTS AND DETERMINING THE
GAME’S OUTCOME.
FUNCTIONS:
PLAYGAME(): MANAGES THE GAME LOOP, INCLUDING
HANDLING GUESSES AND PROVIDING FEEDBACK UNTIL THE
PLAYER EITHER GUESSES THE CORRECT NUMBER OR RUNS
OUT OF ATTEMPTS.
CHECKGUESS(INT GUESS, INT TARGET): DETERMINES IF THE
PLAYER’S GUESS IS CORRECT, TOO HIGH, OR TOO LOW.
4.GAME END MODULE

PURPOSE: TO HANDLE THE END OF THE GAME, WHETHER


THE PLAYER WINS OR LOSES.
FUNCTIONS:
DISPLAYRESULT(BOOL WON, INT TARGET): DISPLAYS THE
RESULT OF THE GAME, INFORMING THE PLAYER IF THEY
WON OR LOST AND SHOWING THE TARGET NUMBER IF
THEY LOST.
PLAYAGAIN(): ASKS THE PLAYER IF THEY WANT TO PLAY
ANOTHER ROUND AND RESTARTS THE GAME IF DESIRED.
Input
PLAYER’S GUESS:
TYPE: INTEGER
DESCRIPTION: THE NUMBER THAT THE PLAYER GUESSES IN AN
ATTEMPT TO MATCH THE RANDOMLY GENERATED NUMBER.
PROMPT: "ENTER YOUR GUESS: "
PLAY AGAIN OPTION:
TYPE: CHARACTER (USUALLY 'Y' OR 'N')
DESCRIPTION: THE PLAYER'S CHOICE TO CONTINUE PLAYING
ANOTHER ROUND OR EXIT THE GAME.
PROMPT: "DO YOU WANT TO PLAY AGAIN? (Y/N): "
OUTPUT
FEEDBACK MESSAGES:
DESCRIPTION: PROVIDES HINTS BASED ON THE PLAYER’S GUESS.
EXAMPLES:
"TOO HIGH! TRY AGAIN."
"TOO LOW! TRY AGAIN."
"CONGRATULATIONS! YOU GUESSED THE NUMBER."
GAME RESULT:
DESCRIPTION: INDICATES WHETHER THE PLAYER WON OR LOST AND REVEALS THE
CORRECT NUMBER IF THE PLAYER DIDN’T GUESS IT.
EXAMPLES:
"YOU WON THE GAME IN 7 ATTEMPTS!"
"YOU'VE RUN OUT OF ATTEMPTS. THE CORRECT NUMBER WAS 42."
REPLAY PROMPT:
DESCRIPTION: ASKS THE PLAYER IF THEY WANT TO PLAY ANOTHER ROUND.
58
1 9
THAN
K YOU

You might also like