0% found this document useful (0 votes)
25 views2 pages

Program For The Game Rock,: Paper and Scissor

The program allows a player to play rock, paper, scissors against a computer. The program gets input from the player for their choice, randomly selects a choice for the computer from an array of options, and outputs the choices and result of whether the player won, lost, or tied against the computer. It includes if/else statements to cover the different combinations of choices and results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Program For The Game Rock,: Paper and Scissor

The program allows a player to play rock, paper, scissors against a computer. The program gets input from the player for their choice, randomly selects a choice for the computer from an array of options, and outputs the choices and result of whether the player won, lost, or tied against the computer. It includes if/else statements to cover the different combinations of choices and results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PROGRAM FOR THE GAME ROCK,

PAPER AND SCISSOR

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
Void main()
{
string input;
cin>>input;
cout<< “the player chose”<<input<<endl;
string choices[3]={“rock”, “paper”, “scissor”};
string chosen=choices[rand()%3];
cout<< “The Computer Chose”<<chosen<<endl;
cout<< “RESULTS”<<ENDL;
string tie= “Tie!”;
string lost= “You Lost!”;
string won= “You Won!”;
if(input==chosen)
cout<<tie;
else if( input== “rock” && chosen== “scissor”)
cout<<won;
else if ( inpit== “rock” && chosen== “paper”)
cout<<lost;
else if( input== “paper” && chosen== “rock”)
cout<<won;
else if(input== “paper” && chosen== “scissor”)
cout<<lost;
else if(input== “scissors”&&chosen== “paper”)
cout<<won;
else if( input== “scissors”&& chosen== “rock”)
cout<<lost;
else
cout<< “\nInvalid Input!!!!”<<endl<< “Plz Try Again”
getch();}

You might also like