The user will enter: "C is fun!" and then presses enter then cntl-d?
(the isalpha() function will return a 1 if the character is between a-z or A-Z and a 0 otherwise. Hitting cntl-d is equivalent to 'EOF')
#include <stdio.h>
#include <ctype.h>
void main()
{
char ch;
int count = 0;
while ( (ch = getchar()) ! = 'EOF')
{
if (isalpha(ch))
count++;
}
printf("%d\n", count);
}