So I am going through the "Jumping into C++" ebook and I have hit a road block with random numbers.... I want to make two separate random number choosers, one that will be the answer and another to be a random guesser to keep guessing until it guesses that same number, but when I have my program run it just guesses the same number an infinite amount of times and I get hit into a infinite loop. Can anyone help me make the guesser choose different numbers every time it runs the loop... I am stumped
Code:#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { srand(time(0)); int answer = (rand() % 10) + 1; int choice = (rand() % 10) + 1; int newChoice = 0; int attempts = 1; cout << "Hello, Computer. How many attempts will it take you to guess my number?" << endl; cout << answer << endl; while(answer != choice){ choice cout << "Attempt: " << attempts << " You guessed: " << choice << endl; attempts++; } cout << "Congratulations Computer!" << endl; cout << "You guessed " << attempts << " times."; }