Hello (C++) programmers of southperry. I'm having a really simple problem with this code that I can't figure out.
My compiler says I have a "declaration error" at the line:
} while (playersRespond != 3);
I have no idea what I'm doing wrong.
edit: does it have something to do with me saying "while (playersRespond != 3)" when i already have an "else" statement within the "do"?
Code:
int main()
{
srand(time(NULL));
int upperBound = 100;
int lowerBound = 1;
int range = upperBound - lowerBound;
int guess = 1 + rand() % range;
char playersRespond;
cin >> playersRespond;
do {
if (playersRespond == '1') {
//do something;
} else if (playersRespond == '2') {
//do something;
} else {
cout << "Please type in 1, 2 or 3" << endl;
}
} while (playersRespond != 3);
char c;
cin >> c;
return 0;
}My compiler says I have a "declaration error" at the line:
} while (playersRespond != 3);
I have no idea what I'm doing wrong.
edit: does it have something to do with me saying "while (playersRespond != 3)" when i already have an "else" statement within the "do"?

