dimanche 29 août 2021

What is the issue with the syntax error I am receiving? [closed]

I am having an issue when trying to work on a rock, paper, scissors game. I am getting an error:

Error: expected ';' before '{' token

I have looked over my code to the best of my ability, but I am not having any luck solving the issue. It is my second day learning, so I would appreciate any feedback.

#include <iostream>

using namespace std;

int rock = 1;
int paper = 2;
int scissors = 3;   

int main()
{
    cout << "Rock, paper, or scissors?: " << endl;
    cout << "1: Rock" << endl;
    cout << "2: Paper" << endl;
    cout << "3: Scissors" << endl;
    cout << "Enter your choice: ";
    int userChoice;
    cin >> userChoice;

    if(userChoice = 1){
        cout << "You choose rock";
    }
    else(userChoice = 2){
        cout << "You chose paper";
    }else(userChoice = 3){
        cout << "You chose scissors";
    }

Aucun commentaire:

Enregistrer un commentaire