This repository contains my C programming project called Guess the Random Number. In this game, the user tries to guess a randomly generated number between 0 and 999. The program will guide the user by indicating if the guessed number is higher or lower than the randomly generated number, until the correct number is guessed. The number of attempts is also counted and displayed at the end of the game.
- Generates a random number between 0 and 999.
- Gives feedback if the guessed number is too high or too low.
- Displays the total number of attempts to guess the correct number.
- Simple and interactive command-line interface.
To run this program on your local machine, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/yourusername/guess-the-random-number-game.git
- Navigate to the project directory:
cd guess-the-random-number-game
- Compile the C program using a C compiler like GCC:
gcc -o guess_the_random_number guess_the_random_number.c
- Run the compiled program:
./guess_the_random_number
- Gameplay: The program will ask you to input a guess. Based on your input, it will tell you whether the random number is higher or lower, until you guess it correctly. It will also display the number of attempts at the end.
The main logic behind this program is fairly simple:
- Random Number Generation: The program uses the rand() function seeded with the current time (srand(time(0))) to generate a random number between 0 and 999.
- User Input: The user guesses a number and the program provides feedback based on whether the guess is higher or lower than the random number.
- Loop: The program keeps looping until the user guesses the correct number.
- Counting Attempts: Each wrong guess increments the number of attempts.
- C Programming Language: The game is entirely coded in C.
- GCC Compiler: Used to compile the C program.
- Random Number Generation: rand() function is used for generating random numbers.
Here are a few ideas for future improvements:
- Difficulty Levels: Add difficulty levels where the range of random numbers could vary (e.g., easy: 0-50, medium: 0-500, hard: 0-999).
- Hint System: Provide more detailed hints to the user (e.g., "You're very close!" or "You're far off!").
- Multiplayer Mode: Allow two players to take turns guessing.
- Graphical Interface: Implement a simple GUI for a more user-friendly experience.
Vineet Verma
- Hi! I'm currently pursuing my Bachelors of Technology in Artificial Intelligence & Machine Learning (AIML), i'm passionate about coding and learning new programming languages.
- GitHub: Vineet-Verma22
- Feel free to contribute or suggest enhancements!