Simple Dice Game Syntax Errors

hey guys thanks in advance. I am trying to simulate two dice rolls, and compare the results. I am getting some kind of error at line 51, with my if statements. all help appreciated

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  #include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;

void airoll();



int main()
{




    srand(time(0));  //random die roll
            int rollResult = 1+(rand()%6);

        switch (rollResult) //results options
    {
        case 1:
        {
            cout<<"Your Roll: 1"<<endl;
        }break;
        case 2:
            {
                cout<<"Your Roll: 2"<<endl;
            }break;
        case 3:
        {
            cout<<"Your Roll: 3"<<endl;
        }break;
        case 4:
        {
            cout<<"Your Roll: 4"<<endl;
        }break;
        case 5:
        {
            cout<<"Your Roll: 5"<<endl;
        }break;
        case 6:
        {
            cout<<"Your Roll: 6"<<endl;
        }break;
    }
    airoll();



    if (rollResult>aiRollResult)
        {
            cout<<"You win!"<<endl;
        }
    if (aiRollResult>rollResult)
        {
            cout<<"You lose!"<<endl;
        }

   if (rollResult==aiRollResult)
        {
            cout<<"It's a tie!"<<endl;
        }

}



void airoll()
{
            int aiRollResult=1+(rand()%6);
        cout<<"AI roll: "<<aiRollResult<<endl;

}
Where did you define aiRollResult? I only see it in the airoll function, which discards it after printing its value.
Topic archived. No new replies allowed.