Sorry i am a complete noob i cannot seem to get the do-while loop to keep running until it meets the answer of valueGuessed == RandomNumber. Im trying to generate a random number which works, however the do-while loop is suppose to run again until the random number meets the number guessed, and it wont do that. Many thanks in advanced!
[# include <iostream>
# include <stdlib.h>
# include <time.h>
using namespace std;
void getGuess(int& valueGuessed)
{
cout << "I have a number between 1 and 1000" << endl;
cout << "Can you guess my number?" << endl;
cout << "Please type your first guess: " << endl;
valueGuessed = 0;
cin >> valueGuessed;
cout << "Your value is: " << valueGuessed << endl;
}
int isCorrect(int& valueGuessed, int& randomNumber)
{
srand(time(0));
randomNumber = 1 + rand()%1000;
do
{
if (valueGuessed < randomNumber)
{
cout << "Too low. Try again" << endl;
return(valueGuessed);
Since Your is the opposite of what you want as @Texan40 showed, you just have to do the opposite of the opposite to get it back on track right? So basically
while(valueGuessed != randomNumber) // this will run as long as the guessed value is not equal to the random number.