Welcome to the Rock, Paper, Scissors game! This is a simple command-line game where you play against the computer. Choose Rock, Paper, or Scissors, and see who wins!
This project is a basic implementation of the Rock, Paper, Scissors game in C. It demonstrates fundamental concepts such as user input, random number generation, and simple decision-making.
- Play Rock, Paper, Scissors against the computer 🤖
- Clear and informative output 💬
- Randomized computer choices 🎲
- Simple and easy-to-understand code 🧩
-
Clone the Repository:
git clone https://github.com/mdriyadkhan585/rock-paper-scissors-C.git
-
Navigate to the Project Directory:
cd rock-paper-scissors-C
-
Compile the Code: Use a C compiler like
gcc
:gcc -o rock_paper_scissors rock_paper_scissors.c
-
Run the Program:
./rock_paper_scissors
-
Start the Game: After running the program, you’ll be prompted to enter your choice.
-
Enter Your Choice:
- Type
0
for Rock 🪨 - Type
1
for Paper 📄 - Type
2
for Scissors ✂️
- Type
-
View the Results: The program will display the computer's choice and the result of the game (win, lose, or tie).
-
Play Again: You can run the program again to play another round.
-
Getting the Computer's Choice:
int getComputerChoice() { return rand() % 3; // 0 = Rock, 1 = Paper, 2 = Scissors }
-
Determining the Winner:
void determineWinner(int playerChoice, int computerChoice) { // Compares choices and prints the result }
-
User Input and Validation:
- Prompts the user to enter their choice
- Validates the input to ensure it's between 0 and 2
-
Formatted Output:
- Displays user and computer choices
- Announces the result in a clear and engaging format