My for loop doesn't seem to be executing. When i run the program it seems for loop is been skipped. Can someone please help me out.
#include <stdio.h> #include <cs50.h> #include <string.h> #include <math.h>
int main (void) { int letters=0, words=0, sentences=0; char text[100]; printf("Enter text:"); scanf("%s",&text[100]); //To prompt the user to type in text
for(int i=0 ; i<strlen(text); i++) //Loop to count letters words and sentences
{
if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
{
letters++;
}
else if (text[i] == ' ')
{
words++;
}
else if (text[i] == '.' || text[i] == '!' || text[i] == '?')
{
sentences++;
}
}
printf("Letters: %i\nWords: %i\nSentences: %i\n", letters, words, sentences);
}