title: Program to count lines words and characters in c
body: <p>In this code I want to count number of characters newlines and words.
  But there is some problem in second while loop which I am not able to understand; also code is showing no output.</p>
  
  <pre><code>//program to count newlines new words and characters
  
  #include&lt;stdio.h&gt;
  int main()
  {
      int c;
      int nl,nw,nc;//nl=newline,nw=new word,nc=new charcacter
      nl=nw=nc=0;
      while((c=getchar())!=EOF)
      {
          nc++;
          if(c=='\n')
          nl++;
          else if(c!=(' ')||c!=('\n'))
          {
              nw++;
              while(c!=' '||c!='\n')
              { 
                  c=getchar();
                  nc++;
              }
              nc++;
          }
      }
      printf("%d %d %d",nl,nc,nw);
  }
  </code></pre>