Skip to content

Instantly share code, notes, and snippets.

@saiedabbas93
Last active January 8, 2022 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saiedabbas93/5c7a0af630847c38f2bfb13171793865 to your computer and use it in GitHub Desktop.
Save saiedabbas93/5c7a0af630847c38f2bfb13171793865 to your computer and use it in GitHub Desktop.
STONE/ROCK PAPER SCISSORS GAME BETWEEN TWO PLAYERS IN C PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
char player1[10],player2[10];
int in1,in2;
printf("HELLO, WELCOME TO ROCK, PAPER, SCISSORS GAME\nWhat is player1's name?\n ");
scanf("%s",&player1);
printf("What is player2's name?\n ");
scanf("%s",&player2);
printf("%s and %s please follow the rules for the game\nPress 1 for stone\nPress 2 for paper\nPress 3 for scissors\n\n",player1,player2);
printf("Now let us start the game\n");
printf("%s is it STONE 1, PAPER 2 OR SCISSORS 3\n",player1);
scanf("%d",&in1);
printf("%s is it STONE 1, PAPER 2 OR SCISSORS 3\n",player2);
scanf("%d",&in2);
if ((in1==1 && in2==1) || (in1==2 && in2==2) || (in1==3 && in2==3))
printf("Neither %s nor %s won, it is a draw",player1,player2);
else if ((in1==1 && in2==3) || (in1==3 && in2==2) || (in1==1 && in2==3)|| (in1==2 && in2==1) || (in1==3 && in2==2) || (in1==1 && in2==3))
printf("Congrats %s! You won!!!!",player1);
else if ((in1==1 && in2==2) || (in1==3 && in2==1) || (in1==1 && in2==2)|| (in1==2 && in2==3))
printf("Congrats %s! You won!!!!",player2);
}
@23182810
Copy link

23182810 commented Jan 8, 2022

If the 2nd person was a computer, how would it be written?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment