### Guessing Game Help

How can i separate this game into 4 rounds please i need immediate help, this program is due tomorrow.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475`` ``````#include #include #include using namespace 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 "<> 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; }``````

Last edited on
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
 ``1234`` ``````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.

Well, your current loop is using the assignment operator( = ) instead of the equal-to operator (== ). I cant imagine that this is intentional.
Last edited on
Topic archived. No new replies allowed.