@Tempus
#include <cstdlib>
#include <iostream>
#include <ctime>
I have those ^. The "(playersRespond != '3')" might be the problem. It's a huge facepalm if it is. I don't have an IDE I can access until tomorrow so I can't check it (not to mention the actual code is in my lab's computer lol. This is one of the earlier saved code.)
Anyway if that isn't the problem, can it be something else?
@Fiel, I originally didn't have playersRespond as numbers. I want it to loop through 1 and 2 if the players types in anything that isn't 3.
edit: revised code based on Fiel's and Tempus' help
#include <cstdlib>
#include <iostream>
#include <ctime>
I have those ^. The "(playersRespond != '3')" might be the problem. It's a huge facepalm if it is. I don't have an IDE I can access until tomorrow so I can't check it (not to mention the actual code is in my lab's computer lol. This is one of the earlier saved code.)
Anyway if that isn't the problem, can it be something else?
@Fiel, I originally didn't have playersRespond as numbers. I want it to loop through 1 and 2 if the players types in anything that isn't 3.
edit: revised code based on Fiel's and Tempus' help
Code:
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(NULL));
int upperBound = 100;
int lowerBound = 1;
int range = upperBound - lowerBound;
int guess = 1 + rand() % range;
int 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;
}
char c;
cin >> c;
} while (playersRespond != '3');
return 0;
}
