Problem with my code while using String

What is wrong with this code? Could anyone fix it? I keep getting D:\scorerecorder\main.cpp|25|error: expected ';' before string constant|. on most lines as soon as I used the "if/else values I believe"

What I want is for it to display the winning team ( The winning team has a summed up value of 16 ) or if both got 15 it's a draw (It's based off of CSGO :) )

Thanks in advance, here is the content (code)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
     #include <iostream>


    using namespace std;

    int main()
    {
    int ya;
    int yb;
    int ysum;
    int ea;
    int eb;
    int esum;
    string teamname1;
    string teamname2;

    cout << "Enter the first team name" << endl;
    cin >> teamname1;
    cout << "Second team name" << endl;
    cin >> teamname2;

    cout << teamname1 << " first half score" << endl;
    cin >> ya;

    cout << teamname1 << " second half score" << endl;
    cin >> yb;

    ysum = ya + yb;
    cout << ysum << teamname1 << " round total" << endl;

    cout << teamname2 << " first half score" << endl;
    cin >> ea;

    cout << teamname2 << " second half score" << endl;
    cin >> eb;

    esum = ea + eb;
    cout << esum << teamname2 << " score" << endl;

    cout << " Final Score is";
    cout << teamname1 << " " << ysum << "-" << esum << " " << teamname2 << endl;
    cout << "Good Game!";





    }
Last edited on
Oh dear I'm so silly, forgot so many <<'s

Need Help on how to do the "if" bit now, so for example whichever team has 16 points it displays

cout << teamname1 << cout << " Has won"

Edited the code now.
Last edited on
try to declare variables first when you have a meaningfull value to give them.
That might not compile for some compilers, because you are missing <string> header.

I cannot reproduce your problem. Input works just fine.
Topic archived. No new replies allowed.