I have to make a rock paper scissors game, have to use value returning function and not allowed to use void method. please check my program, why it's not working.
#include<iostream>
#include<cstdlib>
#include<string>
#include<ctime>
using namespace std;
int winner(int, int);
int main ()
{
char selection;
int rpsSel;
int compSel;
compSel = rand()%2+1;
srand((unsigned)time(0));
do
{
cout << endl;
cout <<"ROCK PAPER SCISSORS MENU\n";
cout <<"------------------------\n";
cout << "p) Play Game\n";
cout << "q) Quit\n";
cout << "Please enter your choice : \n";
cin >> selection;
if (selection == 'q')
{
cout << "You have chosen to quit the program. Thank you for using the program!" <<endl;
}
else if (selection == 'p')
{
cout << "Rock, Paper, or Scissors?\n";
cout << "1) Rock\n";
cout << "2) Paper\n";
cout << "3) Scissors\n";
cout << "Please enter your choice : \n";
cout << "\n";
cin >> rpsSel;
cin >> compSel;
cout << "You chose : " << rpsSel <<endl;
cout << "The computer chose : " << compSel <<endl;
cout <<endl;
Your int winner(int, int); function is supposed to return an integer but it dosn't. If you need to return something just to please your teacher. You could return a string instead, such as return"You win!";You also have statements like this (compSel = 1) this should be an equality statement not an assignment statement.