I need help in executing the program here. This is my program and when I execute it, it asks me for a text. I copy-pasted the first HOW TO TEST YOUR CODE "One fish. Two fish. Red fish. Blue fish." from the Readability tab in cs50x. My program should print the grade level of the inputted text yet it doesn't and just moves the cursor to the next line. It doesn't end there. If I type something else it just stays there and I press enter and once again it just moves the cursor to the next line. Can someone please look into it and tell me what I've doing wrong. Here is the code I used if anyone can run it and see whats wrong:
#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <math.h>
int main(void) { string s = get_string("Text: "); int num_words, num_sentences, num_letters; num_words = num_sentences = num_letters = 0; for (int i = 0, len = strlen(s); i < len; i++) { if (isalpha(s[i])) num_letters++; if ((i == 0 && s[i] != ' ') || (i != len - 1 && s[i] == ' ' && s[i =1] != ' ')) num_words++; if (s[i] == '.' || s[i] == '?' || s[i] == '!') num_sentences++; } float L = (num_letters / (float) num_words) * 100; float S = (num_sentences / (float) num_words) * 100; int index = round(0.0588 * L - 0.296 * S - 15.8); if (index < 1) printf("Before grade 1\n"); else if (index >= 16) printf("Grade 16+\n"); else printf("Grade %i\n", index);