When I was doing the bracketing search problem from this page: http://cplusplus.com/forum/articles/12974/, I ran into trouble with the random number generation. When I call the random number function through the while loop, the program gives me a random answer (i.e it tells me 5 is correct when I put in 3).
Every call to rand1to10 returns a random number. The number you generate and compare to answer is probably not the same value you get when you feed it to cout.
1 2 3 4 5 6 7 8 9 10 11
while(true){
int guess = rand1to10();
if (answer == guess){
cout << guess << " is the right answer.";
break;
}
else {
cout << guess << endl;
}
}