Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

GUESS THE NUMBER

Submitted by

VAIBHAV DINESH MARATHE


Roll No: 28
HARSHAD GANESH HADAP
Roll No: 16
PREM CHANDRASHEKHAR HADAP
Roll No: 17

Under the Guidance of


PROF. D.S.SONAWANE

DEPARTMENT OF COMPUTER ENGINEERING

KONKAN GYANPEETH COLLEGE OF ENGINEERING

UNIVERSITY OF MUMBAI
(2023-2024)
CERTIFICATE

This is to certify the project entitled “Currency Converter” is a bonafide work


of Vaibhav Dinesh Marathe(28), Harshad Ganesh Hadap(16),Prem Chandrashekhar
Hapad(17)” submitted to be University of Mumbai in partial fulfilment of the requirement
for the award of the degree of “S.E.” in “Computer Engineering”

Project Guide

PROF. D.S.SONAWANE

Department of Computer Engineering


ABSTRCT

One of the simplest two-player games is “Guess the number”. The first player thinks of a secret
number in some known range while the second player attempts to guess the number. After each
guess, the first player answers either “Higher”, “Lower” or “Correct!” depending on whether
the secret number is higher, lower or equal to the guess. In this project, you will build a simple
interactive program in where the computer will take the role of the first player while you play
as the second player.

You will interact with your program using an input field and several buttons. For this project,
we will ignore the canvas and print the computer's responses in the console. Building an initial
version of your project that prints information in the console is a development strategy that you
should use in later projects as well. Focusing on getting the logic of the program correct before
trying to make it display the information in some “nice” way on the canvas usually saves lots
of time since debugging logic errors in graphical output can be tricky.
Acknowledgement

We would take this opportunity to thank our project guide PROF. D.S.SONAWANE
for providing timely assistant to our query and guidance that he gave owing to his experience
in this age for past many months. he had indeed been a lighthouse for us in this journey.
INDEX

1. Introduction………………………………………………………………………………….

2. System Analysis……………………………………………...………………………...

3. Objective………………………………………………………………………………

4. Algorithm………………………………………………………………………………...

5. Flowchart ……………………………………………………………………………

6. Requirements ………………………………………………………………………...

7. Implementation………………………………………………………………………...

8. Outputs……………………………………………………………………………….....

9. Conclusion……………………………………………………………………………....

10. References………………………………………………………………………………
1.INTRODUCTION

The number guessing game in C is a project that is aimed at designing a simple game, where
the computer generates a random number between 1-100 and the user has to guess that number
in the minimum number of turns. In this article, we will not only discuss how to build the game,
but also discuss the best possible strategy and approaches to win the above game.

The number guessing game is a game where the computer generates a random number and we
need to guess that number in minimum tries. After every try, the computer will tell us whether
our guess was smaller, larger, or equal to the random computer-generated number and if the
number we guessed wasn’t equal to the computer generated number then we can try again until
we get the correct guess. The random number in the game is between 1 to 100. We'll be looking
at how we can implement this project in C, but before that let us go through the pre-requisites
for the project.

The game is built using C programming language and is run in the terminal. The program code
makes use of the built in function in C to generate a random number and also one of the standard
looping methods which is the do-while loop for the functionality of the game. We keep playing
the game till the user guesses the correct answer or stops the game. We keep on taking the next
guess from the user and compare it with the generated number until the user's guess matches
with the generated number.
2.SYSTEM ANALYSIS

1.Purpose of the System:


The system is designed to engage users in a simple number-guessing game. It generates a
random number within a specified range and prompts users to guess the number. It provides
feedback based on the user's guesses until they guess the correct number.

2. Functional Requirements:
- Generate a random number within a specified range.
- Accept user input for the guessed number.
- Provide feedback to the user indicating whether the guess is too high or too low.
- Track the number of attempts made by the user.
- Display the number of attempts taken to guess the correct number.

3. Non-Functional Requirements:
- Usability: The game should be user-friendly and easy to understand.
- Performance: The system should generate random numbers efficiently and provide quick
feedback to the user's guesses.
- Reliability: The system should consistently generate random numbers and handle user
inputs accurately.
- Scalability: The system should be able to handle multiple users playing the game
simultaneously.
- Maintainability: The code should be well-structured and documented for easy
maintenance and updates.

4. Constraints:
- The system should work within a predefined range of numbers.
- It should be developed using programming languages and libraries that support random
number generation and user input/output operations.
- The user interface should be kept simple and intuitive.
5. Assumptions:
- Users have a basic understanding of how to play a number-guessing game.
- Users have access to a computing device capable of running the program.

6. Risks:
- Inaccurate random number generation could affect the fairness of the game.
- Input errors from the user could lead to unexpected behavior.
- Inadequate error handling might lead to crashes or undesired outcomes.

.
3.OBJECTIVE
The main objective of the "Guess the Number" game is to provide entertainment and
engagement to the players through a simple and interactive guessing experience. While the
game itself may seem straightforward, it serves various specific objectives, including:

1. Entertainment: The primary goal is to entertain players by engaging them in a challenging


and interactive game that involves using their intuition and logic to guess a randomly generated
number within a certain range.

2. Cognitive Stimulation: The game encourages players to use their critical thinking skills,
including logical reasoning and deduction, to make informed guesses and ultimately arrive at
the correct number. This process can help stimulate cognitive abilities, particularly in terms of
problem-solving and decision-making.

3.User Engagement: By providing immediate feedback on each guess, the game keeps the
players engaged and motivated to continue making attempts until they successfully guess the
number. This engagement can contribute to a positive user experience and promote continued
participation.

4. Skill Development: While seemingly simple, the game can assist in the development of
various skills, including numerical intuition, probability assessment, and perseverance. Players
can refine their understanding of numerical relationships and improve their decision-making
abilities through repeated play.

5. Enjoyable Learning Experience: The game can serve as a fun and interactive platform for
individuals, particularly children, to learn about numbers, logic, and probability in an enjoyable
and non-intimidating manner. It can foster an interest in mathematics and encourage further
exploration of related concepts.

By fulfilling these objectives, the "Guess the Number" game can provide an enjoyable and
intellectually stimulating experience for players of different ages, fostering cognitive
development and promoting a positive attitude towards numerical challenges.
4. ALGORITHM

Step 1: Set the range of possible numbers (e.g., 1 to 100).

Step 2: Generate a random number within the specified range.

Step 3: Initialize a variable to keep track of the number of attempts, setting it to 0 initially.

Step 4: Display the game instructions, prompting the player to guess a number within the
specified range.

Step 5: Read the player's input as their guess.

Step 6: Compare the player's guess with the generated number.

Step 7: If the guess is correct, display a success message, the number of attempts, and end the
game.

Step 8: If the guess is incorrect, provide a hint to the player, indicating whether the guess was
too high or too low.

Step 9: Allow the player to make another guess and increment the attempt counter by 1.

Step 10: Repeat steps 5-9 until the correct number is guessed.

Step 11: Provide the option for the player to play again or exit the game.

Step 12: Handle any input validation to ensure the player's input is within the specified range
and is of the correct data type.

Step 13: Optionally, include error handling to deal with any unexpected scenarios that may
occur during the game.
5.FLOWCHART
6.REQUIREMENTS

• Hardware:

• Processor: i3 or any other

compatible processor

• RAM: 4 GB or more

• Hard disk: 16 GB or more

• Software:

• Notepad, vscode, with java compiler installed in a machine


7.IMPLEMENTATION:

Import java.util.Scanner;

import java.util.Random;

public class Main {

public static void main(String[] args) {

int number, guess, n_guesses = 1;

Random rand = new Random();

number = rand.nextInt(100) + 1;

// System.out.println("The number is " + number);

Scanner scanner = new Scanner(System.in);

do {

System.out.println("Guess the number between 1 to 100");

guess = scanner.nextInt();

if (guess > number) {

System.out.println("Lower number please!");


} else if (guess < number) {

System.out.println("Higher number please!");

} else {

System.out.println("You guessed it in " + n_guesses + " attempts");

n_guesses++;

} while (guess != number);

scanner.close();

}
8.OUTPUTS
9.CONCLUSION:

In conclusion, the "Guess the Number" game implemented in the C programming language
provides an entertaining and engaging experience for users. Through the development and
analysis of this game, several key points can be highlighted:
The game successfully engages users by prompting them to guess a randomly generated
number within a specified range. With immediate feedback provided based on their guesses,
users are motivated to continue playing until they successfully guess the number.
10.REFERENCES:

https://www.geeksforgeeks.org/number-guessing-game-in-c/

https://www3.nd.edu/~lemmon/courses/ee224/web-manual/web-manual/lab6/node4.html

https://www.studocu.com/in/document/savitribai-phule-pune-university/computer-

engineering/guessing-game-ferfwe/41879857

https://learn.saylor.org/mod/book/view.php?id=51083

You might also like