title: programming hangman in c
body: <p>Write an interactive program that plays a game of hangman. Store the word (single word, not multiple words) in an array of characters called word. Create a parallel array called guessed in which there are *’s in place of the letters. If the player guesses correctly, put the letter into the guessed array. Give the player 5 wrong guesses to figure out the word. Assume that the word will be no more than 20 characters.</p>
  
  <p>so my program is compiling and all but the if statement is coming out wrong, it keeps showing me both statements the keep going and the try again.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  
  //function prototypes
  void game(char [], char []);
  
  int main()
  {
      char word[20] = {'d', 'u','c','k'};
      char guessed[20];
      game(word,guessed);   
      getch();
      return 0;   
  } 
  void game(char answer[], char guess[])
  {
      int x = 0;
      char letter;
  
      while (x &lt; 6) 
      {
          scanf("%c",&amp;letter);
  
          if (letter == answer[x])
          {
              guess[x]= letter;
              printf("keep going\n");
          }
          else 
          {
              printf("Try again\n");
          }      
  
          ++x;
      }  
  }
  </code></pre>