Hi guys i just wronte this small program in C using the Notepad++ and Cygwin. So the code is the following:
#include <stdio.h>
int main()
{
int c, i, countLetters, countWords;
int arr[30];
countLetters = countWords = 0;
for(i = 0; i < 30; ++i)
arr[i] = 0;
while(c = getchar() != EOF)
if(c >= '0' && c <= '9')
++arr[c - '0'];
else if (c == ' ' || c == '\n' || c == '\t')
++countWords;
else
++countLetters;
printf("countWords = %d, countLetters = %d\n",
countWords, countLetters );
}
but instead of counting words the program counts words as letters and print them as letters and words = 0... where am i wrong because even my teacher couldn`t give me an answer...