My Readability code keeps on creating the outputs of the wrong grade when I try to execute it. When inputting the text, 'When he was nearly thirteen, my brother Jem got his arm badly broken at the elbow. When it healed, and Jem's fears of never being able to play football were assuaged, he was seldom self-conscious about his injury. His left arm was somewhat shorter than his right; when he stood or walked, the back of his hand was at right angles to his body, his thumb parallel to his thigh", it returns as Grade 14. I do not know what I am doing wrong. I have tried to tinker around some lines but nothing seems to be working. Please help!
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
//index = 0.0588 * L - 0.296 * S - 15.8
// L = Number of letters / 100 words; S = number of sentences / 100 words
int main(void)
{
string text = get_string("Text: ");
// l = letters , s = sentences , w = words
int l = 0;
int s = 0;
int w = 1;
for (int i = 0; i < strlen(text); i++)
{
if (text[i] != '\0')
{
l++;
}
if (text[i]== '.' || text[i] == '!' || text[i] == '?')
{
s++;
}
if (text[i] == ' ')
{
w++;
}
}
float la = 100.00 * ((float)l / w);
float sa = 100.00 * ((float)s / w);
float ind = (0.0588 * la) - (0.296 * sa) - 15.8;
int index = round(ind);
if(ind > 16)
{
printf("Grade 16+\n");
}
else if(ind < 1)
{
printf("Before Grade 1\n");
}
else{
printf("Grade %i\n", index);
}
printf("Number of Letters: %i\n", l);
printf("Number of Sentences: %i\n", s);
printf("Average letters per 100 words: %f\n", la);
}