This is the code for counting characters, words and line in C program. (Pg 20, K&R)Why do we really need the variable "state" or why is it important to know if you are inside the word or outside the word.

Is it not enough if you increase the counter for word whenever you encounter
space, tab or new line?
Code:
#include <stdio.h>

#define IN 1 /*inside a word"
#define OUT 0 /*outside a word"

/* count lines, words, and characters in input */

int main()
{
   int c, nl, nw, nc, state;
   state = OUT;
   nl = nw = nc = 0;

   while ((c = getchar()) != EOF) {
      ++nc;
      if (c == '\n')
         ++nl;
      if (c == ' ' || c == '\n' || c == '\t')
         state = OUT;
      else if (state == OUT) {
         state = IN;
         ++nw;
      }
   }
   printf("%d %d %d\n", nl, nw, nc);
   return 0;
}
Thank You.