Magic Number game
So in my book we were learning about loops, and a perfect example to use a loop was the guess a number game. So I took the code and figured out how to use loops and all that, and even added a thing or 2 to the game. What I want to know is how would I make it so after you win and guess the number, you have the option to play again? I experimented a bit but 5 days of c++ studying, I haven't got the knowledge to do this.
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int guess;
int number;
int response;
number = rand();
cout << "Would you like to play the magic number game?\n";
cout << " 1 for yes or 2 for no\n";
cin >> response;
if(response == 1) {
do {
cout << "Enter your guess: ";
cin >> guess;
if(guess == number) cout << "You're right\nBye\n";
if(guess > number) cout << "You're too high\n";
if(guess < number) cout << "You're too low\n";
}
while(guess != number);
}
else cout << "Bye\n";
return 0;
}

