Beginner in C programming here, i'm currently working on a standard Hangman game. I've encountered a problem which i can't figure out a way to tackle due to my limited knowledge. The game doesn't seem to restart with the initial values that i set at the start of them game when the user gets asked if they want to play a new game. Instead of counting from 5 and down (like when i run the program) it instead counts down from 0 and down (-1,-2,-3 etc) without a limit. Also a new random word doesn't get spawned whenever the user accepts a new game. It just continues on with the same word from the previous game, any suggestions on how i can solve this? Thank you in advance.

```
#include<stdlib.h>
#include<string.h>
#include<time.h>

int main(){

    srand(time(NULL));

    char guessWords[][10] = {
        "chocolate",
        "tea",
        "cream",
        "cats",
        "pizza",
        "phone"

    };

    int randomIndex = rand() % 6;

    int numGuess = 5; 

    int numCorrect = 0; 

    int oldCorrect = 0;

    int lengthofWord = strlen(guessWords[randomIndex]); 

    int loopIndex = 0;

    int letterGuessed[10] = {0,0,0,0,0,0,0,0,0}; 

    char guess[10];
    int letterEnter;

    char play;

    int quit = 0;

    printf("guessWords:%s randomIndex:%d lengthofWord:%d\n",
           guessWords[randomIndex],
           randomIndex,
           lengthofWord);

  do{ 

    while(numCorrect < lengthofWord){ 

          printf("\n\n New round...\nHangman word: ");

         for(loopIndex = 0; loopIndex < lengthofWord; loopIndex++){

            if(letterGuessed[loopIndex] == 1){
                printf("%c",guessWords[randomIndex][loopIndex]);
           }
            else{
               printf("-");
           }
         }   

           printf("\n");

        printf("Numbers Correct:%d\n", numCorrect);   
          printf("Guess a letter: ");
            fgets(guess, 10, stdin);

        if(strncmp(guess, "quit", 4)== 0){
            quit = 1;
            break;
        }
        letterEnter = guess[0];

          printf("Letter Entered: %c",letterEnter);

           oldCorrect = numCorrect;

        for(loopIndex = 0; loopIndex < lengthofWord; loopIndex++){

        if(letterGuessed[loopIndex] == 1){
                continue;
        }
        if(letterEnter == guessWords[randomIndex][loopIndex]){ 
                letterGuessed[loopIndex] = 1; 
                  numCorrect++;

            }
        } 

            if(oldCorrect == numCorrect){
                numGuess--;
                  printf("\nSorry, wrong guess!\n");
                    printf("You have %d more guesses to go.\n",numGuess);
                if(numGuess == 0){
                    break;       
                }
            }
                 else{
                    printf("\nCorrect Guess!\n"); 
                     printf("You have %d more guesses to go.\n",numGuess);
                }    
            }

            if(quit == 1){
                printf("The user quit.\n");
            }
            else if(numGuess == 0){
             printf("  ______\n");
             printf("   |    |\n");
             printf("  (_)   |\n");   
             printf("  /|\\   |\n");            
             printf("   |    |\n");
             printf("  / \\   |\n");
             printf("   _____|");
                printf("\nYou are hanged! The correct word is: %s", 
                guessWords[randomIndex]); 
            }
            else{
                printf("You Win!\n");
            }        
              printf("\nDo you wanna play again?(y/n): \n");
                scanf("%c", &play);

   }while(play == 'y');

     return 0;
}  ```

```