This simple code counts number of sentences entered by checking period, question mark or exclamation mark. However, if I enter " ", it does not count sentences after space. How can I fix this?
int numberSentence(char ch[])
{
    int count=0, i=0;
    while(ch[i] != '\0')
    {
        if(ch[i] == '.' || ch[i] == '?' || ch[i] == '!')
            count++;
        i++;
    }
    return count;
}
int main()
{
    char ch[999];
    printf("Enter sentences:\n");
    scanf("%s", ch);
    printf("Number of sentences is %d", numberSentence(ch));
}
 
     
     
     
     
    