title: How to use Do While loop in "Guess my number " game?
body: <p>I'm working on this simple task called "Guess my number" and Im trying to implement my code so when user guesses the right number the application displays "Congratulations " and allow the user to choose whether to play again or not. I think a do while loop will do it, but Im still not sure how to implement that. Any ideas?. Thank you in advanced!</p>
  
  <p>Here's my code that runs just fine.</p>
  
  <pre><code>        Random random = new Random();
          while (true)
          {
              int randomNumber = random.Next(1, 5);
              int counter = 1;
              while (true)
              {
                  Console.Write("Guess a number between 1 and 5");
                  int input = Convert.ToInt32(Console.ReadLine());
  
                  if (input &lt; randomNumber)
                  {
                      Console.WriteLine("Too low, try again.");
                      ++counter;
                      continue;
                  }
                  else if (input &gt; randomNumber)
                  {
                      Console.WriteLine("Too high, try again.");
                      ++counter;
                      continue;
                  }
                  else
                  {
                      Console.WriteLine("Congratulations. You guessed the number!");
                      break;
                  }
              }
          }
  </code></pre>