title: Do you want to play again
body: <p>Help I have no idea as to where to put the "Do you want to play again" command, I have tried a few variations myself and I have hit a brick wall my game works as it is but I want the extra marks available for completing the game and offering the chance to play again?</p>
  
  <p>I am using Visual Studio 2013 Professional and C++</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;       //ensures that the system clock is set
  
  void main()
  {
  char player1[10];
  srand(time(NULL));              //this command is only required at the start and sets the clock
  
  printf("Please enter your name? - ");
  scanf("%s", player1);           //this command is used to store the players name for us later on within the game
  printf("\n\n");
  
  //The following printf commands issue the rules of the game and ensure that they are printed and viewable
  printf("Welcome %s to the Pairs (Matching Game)\n\n", player1);
  printf("The rules of the game are as follows\n\n");
  printf(" 1. The player should enter a location of card 1 and card 2\n\n");
  printf(" 2. The player should only use a numeric format to enter the\n    location of the card i.e. 11 and 44 this would show only\n    Line 1 box 1 and line 4 box 4\n\n");
  printf(" 3. Should the player enter a location outside of the table\n    range 'You have incorrectly selected a location, please\n    try again' will be displayed\n\n");
  printf(" 4. A player should select 2 cards to be shown if they match\n    the cards are removed\n\n");
  printf(" 5. If a player selects a non matching pair 'Please try again\n    - you've selected an non matching pair' should be displayed\n\n");
  printf(" 6. The object of the game is to match all the pairs in the \n    least amount of turns possible\n\n");
  printf(" 7. The player cannot use any symbol !£$%^&amp;*@~? as these will\n    not be recognised by the game and cause it to freeze resulting\n    in a restarted game\n");
  
  printf("\n");
  
  char ag = 'y' || 'Y';
  do {
      char grid[17] = { 'a', 'a', 'b', 'b', 'c', 'c', 'd', 'd', 'e', 'e', 'f', 'f', 'g', 'g', 'h', 'h' };     //sets the characters used in the grid
      int high = 15;
      int random, random2, temp, card1, card2;
      int low = 0;
      int counter = 0;
      int x = 0;
      int flag = 0;           //this variable is used to identify potential issues
      int turns = 0;      //identifies the variable for the amount of turns taken
  
      for (x = 1; x &lt; 100; x++)           //sets the random loop to vary the selection 100 times prior to selecting a game table
      {
          random = rand() % (high - low + 1) + low;
          random2 = rand() % (high - low + 1) + low;
          temp = grid[random];
          grid[random] = grid[random2];
          grid[random2] = temp;
      }
  
      while ((grid[0] != 'x') || (grid[1] != 'x') || (grid[2] != 'x') || (grid[3] != 'x') || (grid[4] != 'x') || (grid[5] != 'x') || (grid[6] != 'x') || (grid[7] != 'x') || (grid[8] != 'x') || (grid[9] != 'x') || (grid[10] != 'x') || (grid[11] != 'x') || (grid[12] != 'x') || (grid[13] != 'x') || (grid[14] != 'x') || (grid[15] != 'x'))
      {
  
          for (x = 0; x &lt; 16; x++)
          {
              counter++;
              printf("| %c ", grid[x]);   //The grid is shown using this command for testing purposes only must be removed prior to playing
  
              if (counter == 4)
              {
                  printf("\n");
                  counter = 0;
              }
  
          }
  
          printf("\n");
          printf(" Please enter Card 1 : ");  //Enter the location of your first card
          scanf_s("%d", &amp;card1);              //Displays your first card
          printf(" Please enter Card 2 : ");  //Enter the location of your next card
          scanf_s("%d", &amp;card2);              //Displays your second card
          printf("");
          turns = turns + 1;                  //the turns variable has been set to count every attempt at matching cards
  
          if (card1 == 11)                    //This sets the array (location) for card 1
          {
              card1 = 0;
          }
          else if (card1 == 12)
          {
              card1 = 1;
          }
          else if (card1 == 13)
          {
              card1 = 2;
          }
          else if (card1 == 14)
          {
              card1 = 3;
          }
          else if (card1 == 21)
          {
              card1 = 4;
          }
          else if (card1 == 22)
          {
              card1 = 5;
          }
          else if (card1 == 23)
          {
              card1 = 6;
          }
          else if (card1 == 24)
          {
              card1 = 7;
          }
          else if (card1 == 31)
          {
              card1 = 8;
          }
          else if (card1 == 32)
          {
              card1 = 9;
          }
          else if (card1 == 33)
          {
              card1 = 10;
          }
          else if (card1 == 34)
          {
              card1 = 11;
          }
          else if (card1 == 41)
          {
              card1 = 12;
          }
          else if (card1 == 42)
          {
              card1 = 13;
          }
          else if (card1 == 43)
          {
              card1 = 14;
          }
          else if (card1 == 44)
          {
              card1 = 15;
          }
          else
          {
              card1 = -1;
          }
  
          if (card2 == 11)                            // This will set the arrays (location) for card2
          {
              card2 = 0;
          }
          else if (card2 == 12)
          {
              card2 = 1;
          }
          else if (card2 == 13)
          {
              card2 = 2;
          }
          else if (card2 == 14)
          {
              card2 = 3;
          }
          else if (card2 == 21)
          {
              card2 = 4;
          }
          else if (card2 == 22)
          {
              card2 = 5;
          }
          else if (card2 == 23)
          {
              card2 = 6;
          }
          else if (card2 == 24)
          {
              card2 = 7;
          }
          else if (card2 == 31)
          {
              card2 = 8;
          }
          else if (card2 == 32)
          {
              card2 = 9;
          }
          else if (card2 == 33)
          {
              card2 = 10;
          }
          else if (card2 == 34)
          {
              card2 = 11;
          }
          else if (card2 == 41)
          {
              card2 = 12;
          }
          else if (card2 == 42)
          {
              card2 = 13;
          }
          else if (card2 == 43)
          {
              card2 = 14;
          }
          else if (card2 == 44)
          {
              card2 = 15;
          }
          else
          {
              card2 = -1;
          }
          printf("\n\nCARD 1: %d\n", card1);      //printf shows the location of the card selected from 0 to 15
          printf("CARD 2: %d\n\n", card2);        //printf shows the location of the card selected from 0 to 15
  
          if (((card1 &lt; 0) || (card1&gt;15)) || ((card2 &lt; 0) || (card2&gt;15)))
          {
              printf("\nYou have incorrectly selected a location, please try again\n\n");
              flag = 1;
              printf("Flag=%d\n", flag);      //This printf command is just for testing remove prior to playing the game
          }
  
          counter = 0;                        //This resets the counter
  
          for (x = 0; x &lt; 16; x++)        // this means it will only loop the count 16 times
          {
              counter++;      // this will add 1 to the counter
              printf("|   ");
  
              if (card1 == x)
              {
                  printf("%c", grid[card1]);
              }
              else if (card2 == x)
              {
                  printf("%c", grid[card2]);
              }
              else
              {
                  printf(" ");
              }
  
              if (counter &gt; 3)
              {
                  printf("\n");
                  counter = 0;    // This will reset the counter back to zero 
  
              }
          }
          if ((grid[card1] == 'x') || (grid[card2] == 'x'))       //This 'if statment' states if you have made the choice 
          {
              printf("\nUnfortunately you have selected a card already match, please try again\n\n");
          }
          if ((grid[card1] == grid[card2]) &amp;&amp; (grid[card1] != 'x') &amp;&amp; (grid[card2] != 'x') &amp;&amp; (flag == 0)) //This is the 'if statment' that will match the pairs and then mark them as 'x' 
          {
              printf("\nCongratulations you have found a pair!!\n");
              grid[card1] = 'x';
              grid[card2] = 'x';
          }
  
          if (((grid[card1] != grid[card2]) &amp;&amp; (grid[card1] != 'x') &amp;&amp; (grid[card2] != 'x')) &amp;&amp; (flag == 0)) //This 'if statment' states if the guesses are incorrect
          {
              printf("\nOopps remember the cards as you need to try again\n\n");
          }
          }
          printf("\nExcellent %s you have managed to match all the cards correctly in %d turns\n\n", player1, turns);
          printf("Do you want to play again? (y/n)\n\n");
          scanf_s(" %c", &amp;ag);
          printf("\n\n");
  </code></pre>
  
  <p>} while (ag == 'n' || ag == 'N'); //This is the exit statement from the program and ensures that the game can be played on if 'Y' is selected
      printf("\n\nThanks for playing see you again sometime for another \nthrilling game of Matching Pairs!!!\n\n");
  }</p>