#include <iostream>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
srand(time(0));
int start;
int end;
cout<<"Enter the starting value for what your guess can be between ";
cin>>start;
cout<<"Enter the ending value for your guess can be between ";
cin>>end;
int range;
range=(start-end);
int secretNumber = (rand() % range) + start;
int tries = 0;
int round;
int guess;
range=(start-end);
for(int round=0; round<4; round++){
do
{
cout << "Enter a guess for game "<<tries+1<<" ";
cin >> guess;
++tries;
if (guess > secretNumber)
{
cout << "Too high!" << endl << endl;
}
if (guess < secretNumber)
{
cout << "Too low!" << endl << endl;
}
if (guess == secretNumber)
{
cout << "You win! You got it in " << tries << " tries!" << endl;
}
} while (guess = secretNumber);
if (guess == secretNumber)
{
cout << "You win! You got it in " << tries << " tries!" << endl;
}
else
{
cout << "You lose! You used all " << tries << " of your tries." << endl;
}
}
return 0;
}
You havent told us the problem you are having. However, after a quick glance i see that your do-while loop may not be doing what it should do. I think what you want is to
1 2 3 4
do
{
...
}while( guess != secretNumber);
The above code will loop while the user has not guessed the secretNumber.
No its right, i just need the program i have right now in 4 rounds.
For every round you need to guess until you get the number which i have already done but now i need the program to keep on continuing after i have guessed the number 1st time.