Why dose this happen (C programming Run time error) : i have written this code for a wordsearch program however when i run it this happens [(What happens when it runs)][1]
if anyone has any idea why this happens please could you help me m completely lost.

(if indentation is wrong on here just know that it is correct in my actual code)
(new to c programming and Stackoverflow so please be easy on me)

this is the code - 

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    #include <math.h>
 
 
    #define WIDTH 16
    #define HEIGHT 16
    #define NWORDS 6
 
    char wordsearch[HEIGHT][WIDTH];
 
    /* horizontaly */
 
    int canPlaceH (const char * word, int i, int j)
    {
      if ((strlen(word) + j) > WIDTH)
        return 0;
 
      do {
        if ((wordsearch[i][j] != 0) && (wordsearch[i][j] != *word))
          return 0;
        j += 1;
      } while (*++word);
 
      return 1;
    }
 
    void placeH(const char * word, int i, int j)
    {
      do {
        wordsearch[i][j++] = *word;
      }  while (*++word); 
    }
 
    /* verticaly */
 
    int canPlaceV(const char * word, int i, int j)
    {
      if ((strlen(word) + i) > HEIGHT)
        return 0;
 
      do {
        if ((wordsearch[i][j] != 0) && (wordsearch[i][j] != *word))
          return 0;
        i += 1;
      } while (*++word);
 
      return 1;
    }
 
    void placeV(const char * word, int i, int j)
    {
      do {
        wordsearch[i++][j] = *word;
      }  while (*++word);
    }
 
    /* diagonal up */
 
    int canPlaceDU(const char * word, int i, int j)
    {
      int ln = strlen(word);
 
      if (((ln + j) > WIDTH) || ((i - ln) < 0))
        return 0;
 
      do {
        if ((wordsearch[i][j] != 0) && (wordsearch[i][j] != *word))
          return 0;
        i -= 1;
        j += 1;
      } while (*++word);
 
      return 1;
    }
 
    void placeDU(const char * word, int i, int j)
    {
      do {
        wordsearch[i--][j++] = *word;
      }  while (*++word);
    }
 
    /* diagonal down */
 
    int canPlaceDD(const char * word, int i, int j)
    {
      int ln = strlen(word);
 
      if (((ln + j) > WIDTH) || ((i + ln) > HEIGHT))
        return 0;
 
      do {
        if ((wordsearch[i][j] != 0) && (wordsearch[i][j] != *word))
          return 0;
        i += 1;
        j += 1;
      } while (*++word);
 
      return 1;
    }
 
    void placeDD(const char * word, int i, int j)
    {
      do {
        wordsearch[i++][j++] = *word;
      }  while (*++word);
    }
 
    void fillWordsearch(const char ** a, int sz)
    {
      /* first step add words from a */
      const char * used[NWORDS - 1] = { NULL }; /* to not get two times 
    the same word */
 
      for (int w = 0; w != NWORDS; ++w) {
        /* random choice of a word not yet used */
        const char * word;
 
        for (;;) {
          word = a[rand() % sz];
          int i;
 
          /* check not yet used */
          for (i = 0; i != w; ++i)
            if (!strcmp(used[i], word))
              break;
 
          if (i == w) {
            /* not yet used */
            used[w] = word;
            break;
          }
        }
 
 
        /* random placement */
  
        int i, j, d;
        typedef int (*canFunc)(const char *, int, int);
        typedef void (*placeFunc)(const char *, int, int);
        const canFunc canPlace[] = { canPlaceH, canPlaceV, canPlaceDU, canPlaceDD };
        const placeFunc place[] = { placeH, placeV, placeDU, placeDD };
  
        do {
          i = rand() % HEIGHT;
          j = rand() % WIDTH;
          d = rand() % 4;
        } while (!(*canPlace[d])(word, i, j));
        (*place[d])(word, i, j);
 
 
 
    #ifdef DEBUG
      for (int i = 0; i != HEIGHT; ++i) {
        for (int j = 0; j != WIDTH; ++j)
          putchar((wordsearch[i][j] == 0) ? '.' : wordsearch[i][j]);
        putchar('\n');
      }
      putchar('\n');
    #endif
 
      /* second step fill not yet set characters with random lowercase letters */
      int q,w;
 
      for (q = 0; q < HEIGHT; q++)
        for (w = 0; w != WIDTH; ++w)
          if (wordsearch[q][w] == 0)
            wordsearch[q][w] = 'a' + rand() % ('z' - 'a' + 1);
        }
    }
 
    int main()
    {
 
      const char *animalArray[] = {
        "lynx",
        "kitten",
        "cheetah",
        "ape",
        "doe",
        "reindeer",
        "whale",
        "baboon",
        "skunk",
        "dugong",
        "elephant",
        "anteater",
        "chameleon",
        "lizard",
        "horse"
      };
 
      const char *colourArray[] = {
        "red",
        "green",
        "blue",
        "black",
        "pink",
        "yellow",
        "brown",
        "orange",
        "purple",
        "black",
        "white",
        "cyan",
        "maroon",
        "magenta",
        "gray"
      };
 
      const char *videogameArray[] = {
        "fortnite",
        "fifa",
        "hytale",
        "soma",
        "prey",
        "destiny",
        "titanfall",
        "woldenstein",
        "battlefield",
        "fallout",
        "tekken",
        "skyrim",
        "dishonored",
        "uncharted",
        "anthem"
      };
 
      const char *sportsArray[] = {
        "basketball",
        "football",
        "cricket",
        "wrestling",
        "fencing",
        "rowing",
        "volleyball",
        "baseball",
        "hockey",
        "racing",
        "golf",
        "bobsleigh",
        "curling",
        "snowboarding",
        "bowling"
     };
 
      const char *countryArray[] = {
        "england",
        "ireland",
        "china",
        "wales",
        "bangladesh",
        "maldives",
        "slovenia",
        "uruguay",
        "colombia",
        "samoa",
        "jamaica",
        "malta",
        "bulgaria",
        "armenia",
        "gamnbia"
      };
 
      printf("---------------------------------\n");
      printf("| Welcome to the WordSearch Game |\n");
      printf("---------------------------------\n");
      printf("Choose a Category - \n");
      printf("Option 1 - Animals\n");
      printf("Option 2 - Colours\n");
      printf("Option 3 - Video Games\n");
      printf("Option 4 - Sports\n");
      printf("Option 5 - Countries\n");
 
      int i;
 
      if ((scanf("%d", &i) != 1) || (i < 1) || (i > 5))
        return -1;
 
      srand(time(NULL));
 
      switch (i) {
      case 1:
        fillWordsearch(animalArray, 
    sizeof(animalArray)/sizeof(*animalArray));
        break;
      case 2:
        fillWordsearch(colourArray, 
    sizeof(colourArray)/sizeof(*colourArray));
        break;
      case 3:
        fillWordsearch(videogameArray, 
    sizeof(videogameArray)/sizeof(*videogameArray));
        break;
      case 4:
        fillWordsearch(sportsArray, 
    sizeof(sportsArray)/sizeof(*sportsArray));
        break;
      default:
        fillWordsearch(countryArray, 
    sizeof(countryArray)/sizeof(*countryArray));
        break;
      }
 
      /* print result */
      for (i = 0; i != HEIGHT; ++i) {
        for (int j = 0; j != WIDTH; ++j)
          putchar(wordsearch[i][j]);
        putchar('\n');
      }
 
      return 0;
    }

  [1]: https://i.stack.imgur.com/l8pHx.png


