Hi,
I am very new to programming and just started learning C. I have a program that asks the user to input text. The user allowed to enter any ASCII characters they want, it will be terminated when the user enters ctl+Z. In the program I need to find out how many letters in the user's input and the number of words. Only the letters from 'A' to 'Z' and 'a' to 'z' will be counted as words and letters. Also, when the user enters I'm instead of 'I am', it should be counted as two words. So, I did write a program, figured out how to count the letters. Tried to do the word count in different ways. I couldn't get it to work. Any help/hints will be very much appreciated. Thank you in advance. Here is my code:

# include<stdio.h>

main()
{
int ch, letter = 0, word = 0, inword = 0;

printf("Enter lines of text. To terminate, type control-Z: ");
ch = getchar();
//inword = 0;

while(ch!= EOF)
{
if((ch>='A' && ch<= 'Z') || (ch>='a' && ch<='z'))
{
letter++;
ch = getchar();
}
else if(!(ch>='A' && ch<= 'Z') || (ch>='a' && ch<='z'))
{
//if(inword >= ((ch>='A' && ch<= 'Z') || (ch>='a' && ch<='z')))
//{word++;}
ch = getchar();
}
//inword = ch;
}
printf("\n Letters: %d",letter);
//printf("\n Words: %d", word);

return 0;
}