Ok I am have a simple issue that is eluding me badly for some reason I am running a simple loop to get a random num generator to guess 10 different numbers but it keeps guessing the exact same number
This actually made me laugh. If you want it to guess, different numbers each time then you need to tell it to do so, by doing what you did on lines 5 and 6, again in the loop
rand() is the one actually generating random numbers. That is why I thought it was funny that you had the actual random number generator outside the loop
lol man what seemed like such an easy code turned out to bit me in the A*s I got one more question if you don't mine I am doing the have the computer guess my number game and I have this
int _tmain(int argc, _TCHAR* argv[])
{
srand(static_cast<unsignedint> (time(0)));
int guess;
int tries = 0;
int compGuess;
cout << "Please tell us your guess\n";
cin >> guess;
do{
int randomNumber = rand();
compGuess = (randomNumber % 10) + 1;
if (compGuess < guess){
cout << "comp is to low\n";
}
elseif (compGuess > guess){
cout << "comp is to high\n";
}
else{
cout << " the computer guessed correctly with " << compGuess << endl;
}
} while (compGuess != guess);
It seems like its guessing it every single time. I don't know if I am burning myself out or not but it seems like I can't figure out something like this looks ridiculous on me lol
See I was wondering why it would of caused it, you think you can run the one I posted up and see if it does it for you? cuz after I changed the while loop it worked but it makes no sense to me what so ever lol