Thank you for using code formatting tags, but what is your question?
Always compile will warnings enabled
In function 'int main()':
28:6: warning: unused variable 'entry' [-Wunused-variable]
In function 'int exitP(int)':
23:1: warning: control reaches end of non-void function [-Wreturn-type]
You need to seed your random number generator to get different numbers. Make a call to srand(static_cast<unsignedint>(time(0))) before calling rand(). To keep track of the number of guesses, simply increment the numcount by one after the user makes a guess.
Okay, let's simplify your logic a bit, and also use a do-while loop instead of just a while loop, to prevent your logic from checking the guess before the user even guesses.
#include <iostream>
#include <cstdlib>
#include <ctime>
bool exitPrompt()
{
// fill this in yourself,
// have it return true if the user enters 2, false if 1.
returntrue;
}
int main()
{
srand((unsignedint)time(nullptr)); // initialize rand() based on current time
int number = rand() % 10;
int num_tries = 0;
do
{
num_tries++;
std::cout << "Try #" << num_tries << ": try to guess the random number: ";
int guess;
std::cin >> guess;
if (guess > number)
{
std::cout << "You, guessed your number to high, try again\n";
}
if (guess < number)
{
std::cout << "You, guessed your number too low, try again\n";
}
if (guess == number)
{
std::cout << "You, guessed the correct number, What an amazing guess!\n";
std::cout << "your tries: " << num_tries << '\n';
if (exitPrompt())
break;
}
} while (true);
}