PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
In addition to what Repeater said about you for loopI see soe other problems.
If you have to use this you are doing something very wrong. Like maybe putting a C program in a .cpp file and compiling it as a C++ program.
Is n old C style way of writing this line and is no longer used in modern code. It may at the least give you a warning if not an error at compile time.
int r = rand() % 2;
Are backwards. And this
would be better written as
srand(unsigned int (time(0)));
"srand" only needs to be set once at the beginning of the program before "rand" is used.
is causing the need for
With my compiler the error message tells me to use
because it is more secure.
Your for loop deals with one entry for "guess" and does it 10 times because "guess" never changes. At the end of the for loop you need to input a new guess. A do/while or while loop is usually a better choice over the for loop, but it works if done right.
Just my thoughts on your code.
I am nor sure what the best search words would be, but there are many examples here of C++ code that on the sme type of program you could look at.
Hope that helps,