title: C Programming Guessing Game
body: <p>I need help finishing my program. I can't seem to get the last step, when the user enters <code>'y'</code> to play another game it should start again. If the user enters <code>'n'</code> then it should end. Thank you in advance for any help. Below is the code I have so far.</p>
  
  <p>Here is the problem:<br>
  Write a C program that plays a number guessing game with the user.</p>
  
  <p>Below is the sample run:</p>
  
  <pre><code>OK, I am thinking of a number. Try to guess it.
  
  Your guess?  50
  Too high!
  Your guess?  250
  Illegal guess. Your guess must be between 1 and 200.
  Try again. Your guess? 30
  **** CORRECT  ****
  Want to play again?  y
  Ok, I am thinking of a number. Try to guess it.
  Your guess?  58
  ****  CORRECT  ***
  Want to play again? n
  Goodbye, It was fun. Play again soon.
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  
  int main() {
      int i, number, currentGuess, MAX_GUESS = 5;
      int answer = 'n';
      time_t t;
  
      srand((unsigned) time(&amp;t));
      number = rand() % 200 + 1;
  
      printf("Welcome to the game of Guess It! \nI will choose a number between 1 and 200. \nYou will try to guess that number.");
      printf("If you guess wrong, I will tell you if you guessed too high or too low. \nYou have 5 tries to get the number. \n");
      printf("\nOK, I am thinking of a number. Try to guess it. \n");
  
      for (i = 0; i &lt; MAX_GUESS; i++) {
          printf("\nYour guess?");
          scanf("%i", &amp;currentGuess);
  
          if (currentGuess &gt; 200) {
              printf("Illegal guess. Your guess must be between 1 and 200.\n");
              printf("Try again.\n ");
          }
          else if (currentGuess &gt; number) {
              printf("Too high!\n");
          }
          else if (currentGuess &lt; number) {
              printf("Too low!\n");
          }
          else {
              printf("****CORRECT****\n");
              return 0;
          }
      }
  
      printf("Sorry you have entered the maximum number of tries. \n");
      printf("Want to play again? \n");
      scanf("%i", &amp;answer);
  
      if(answer == 'n') {
          printf("Goodbye, it was fun. Play again soon.\n");
          return 0;
      }
      else if (answer != 'n') {
          printf("Ok, I am thinking of a number. Try to guess it.\n");
      }
  }
  </code></pre>