0% found this document useful (0 votes)
4 views8 pages

c project.

Uploaded by

kumaradithya471
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)
4 views8 pages

c project.

Uploaded by

kumaradithya471
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/ 8

Rock Paper Scissors: A C

Programming Game
by Aditya Kumar
Function of Program
The program generates a random choice of rock, paper, The program displays the results, indicating the winner
or scissors for the computer. or a tie.

The user inputs their choice, and the program The program allows the user to play multiple rounds.
compares choices.
The program maintains a score to track the number of
The program determines a winner based on the rules of wins for the user and the computer.
the game.
Use Case Diagram of the
Rock, Paper, Scissors
Game
User System
Plays the game by choosing Generates a random choice,
rock, paper, or scissors. determines the winner, and
displays results.
Explaining the Use Case Diagram
1 1. Play Round 2 2. Get User Choice
The main use case that encompasses all the other The user enters their choice (rock, paper, or scissors).
steps.

3 3. Get Computer Choice 4 4. Determine Winner


The system randomly selects rock, paper, or scissors. The system compares the user's and computer's
choices and determines the winner based on the
rules.
Relationships in the Rock Paper Scissors Game

1 Rock

2 Scissors

3 Paper

Rock beats scissors. Scissors beats paper. Paper beats rock. This forms a circular relationship where each choice
wins over one and loses to another.
Rock Paper Scissor

Scissor Rock Paper


Implementing Rock Paper Scissors in C
Programming
The program uses the `srand` function to seed the
#include <stdio.h>
#include <stdlib.h> random number generator with the current time.
#include <time.h>
The program uses the `rand` function to generate a
int main() { random number between 0 and 2, which is used to
// ... code ...
return 0; represent rock, paper, or scissors.
}
The program uses a series of `if` statements to
compare the user's and computer's choices and
determine the winner.
Conclusion and Key Takeaways

1 2
Simple Logic Randomization
The game's logic is straightforward, Random number generation is key to
relying on a few basic rules that can making the game fair and
be easily implemented in code. unpredictable.

3
Practice
This project provides a good
opportunity to practice basic C
programming concepts such as
input/output, conditional statements,
and random number generation.

You might also like