Program that will simulate the Paper, Rock, Scissors game. Two players should be able to either P, R or S then the program shall determine who the winner is and state why he wins based on the following criteria
Paper covers Rock
Scissor cut paper
Rock breaks scissors
***Sample Output***
PAPER ROCK SCISSORS GAME
Player 1: P Player 2: S
Player 2 wins. Scissors cut Paper
please use ,
#include<stdio.h>
#include<conio.h>
scanf:
printf
#include <stdio.h>
#include <conio.h>
int main()
{
printf("PAPER ROCK SCISSORS GAME\n");
printf("Enter choice for Player 1(P,R, or S): ");
char choiceOfFirstPlayer;
scanf(" %c", &choiceOfFirstPlayer);
printf("Enter choice for Player 2(P,R, or S): ");
char choiceOfSecondPlayer;
scanf(" %c", &choiceOfSecondPlayer);
printf("\n");
printf("Player 1: %c Player 2: %c \n",choiceOfFirstPlayer, choiceOfSecondPlayer);
if(choiceOfFirstPlayer != choiceOfSecondPlayer)
{
if(choiceOfFirstPlayer == 'P')
{
if(choiceOfSecondPlayer == 'R')
printf("Player 1 wins. Paper covers Rock");
else
printf("Player 2 wins. Scissors cut Paper");
}
else if(choiceOfFirstPlayer == 'R')
{
if(choiceOfSecondPlayer == 'P')
printf("Player 2 wins. Paper covers Rock");
else
printf("Player 1 wins. Rock breaks Scissors");
}
else
{
if(choiceOfSecondPlayer == 'R')
printf("Player 2 wins. Rock breaks Scissors");
else
printf("Player 1 wins. Scissors cut Paper");
}
}
printf("\n\n");
return 0;
}
Comments
Who ever code this. You’re awesome. Thank You for your help. God bless
Leave a comment