This project is a simple number guessing game implemented in C. The program generates a random number between 1 and 100, and the user tries to guess the number with hints provided by the program.
- Generates a random number between 1 and 100.
- Provides hints if the guessed number is higher or lower than the generated number.
- Counts the number of attempts taken to guess the number correctly.
- C: The programming language used to implement the game.
- Clone the repository:
git clone https://github.com/Vishwas567917/number-guessing-game.git
- Navigate to the project directory:
cd number-guessing-game
- Compile the code using a C compiler:
gcc -o guessGame guessGame.c
- Run the executable:
./guessGame
Usage
- Run the program.
- Follow the prompt to guess the number between 1 and 100.
- The program will provide hints if your guess is higher or lower than the generated number.
- Keep guessing until you find the correct number.
- The program will display the number of attempts taken to guess the number correctly.
File Structure guessGame.c: Main C file containing the number guessing game implementation. Example Output Guess the number between 1 to 100 50 Lower number please! 25 Higher number please! 30 Higher number please! 35 You guessed in 4 attempt
Additional Code Included in this repository is another simple program to generate and print a random number between 1 and 100.
Example
- Compile the code:
gcc -o generateNumber generateNumber.c
- Run the executable:
./generateNumber
3.The program will print a randomly generated number between 1 and 100.