title: Counting Number of words and Characters in a Sentence using C
body: <p>I tried the below program . </p>
  
  <p>INPUT-: i want help 
  Desired OUTPUT-:Words=3 Characters=9</p>
  
  <p>But the actual output deviates from the desired.
  Can someone tell what is my mistake .</p>
  
  <h1>include </h1>
  
  <pre><code>void main()
  {
    int countch=0;
    int countwd=1;
  
    printf("Enter your sentence in lowercase: ");
    char ch='a';
    while(ch!='\r')
    {
      ch=getche();
      if(ch==' ')
        countwd++;
      else
        countch++;
    }
  
    printf("\n Words = ",countwd);
  
    printf("Characters = ",countch-1);
  
    getch();
  
  }
  </code></pre>