Well, I'm a beginner programmer, and I would like to program games. So I made this game where the user would have to guess the number the computer generated. But I wanted to reverse it. I got two problems one, everytime it generates a number its the same number. The only time it changes is when i close the window and run it again.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
int guess = rand() % 10 + 1;
int tries = 0;
cout << "\tGuess my Number\n\n";
cout << "Think of a Number between 1 - 10.\n";
char answer ;
do
{
cout << "Is you number " << guess << "<Y/N>\n";
cin >> answer;
++tries;
} while (answer == 'N' || answer == 'n');
cout << "\nThat's it I got it in , " << tries << " guesses!\n";
ok well, i didn't know how to change guess, so I put the
int guess = rand() % 10 + 1; in the loop and it works but I don't know it that was the right move.