# Problem Set 2 readability check function returning false negatives

So I understand I have a math error in this code. I assume it is a rounding error which I will eventually get to. In either case, many times I do return the correct grade level but the check50 function is telling me my answer is still wrong. Here is a link to the check50 output.

Here is a link to the code:

disregard the commented out printf functions. I was trying to zero in on some problems.

``````#include <stdio.h>
#include <cs50.h>
#include <string.h>

float L (int a, int b); //calculates letters per words
float S (int x, int y); //calculates words per sentence

int main (void)
{
int letters = 0;
int words = 0;
int sent = 0;
float index = 0;

string t = get_string("Enter a line of text for grading:  ");

for(int i=0; i<strlen(t); i++)
{
if(t[i]!=32 && t[i]!=33 && t[i]!=46 && t[i]!=63) //discounts characters that are not letters
{
letters++;
}
if(t[i]==32|| t[i]==33 || t[i]==46 || t[i]==63) //determines how to count words by looking for punctuiation and spaces
{
words++;
}
if (t[i]==33 || t[i]==46 || t[i]==63)// looks for sentences by finding punctiuation

{
sent++;
}
if (t[i]==32 && (t[i-1]==32 || t[i-1]==33 || t[i-1]==46 || t[i-1]==63)) //corrects for two spaces after punctuation
{
words--;
}
}

index = .0588*L(letters, words)-.296*S(words, sent)-15.8; //index formula

if(index<1) //output loops
{
}
if (index>1 && index < 16.5)
{
}
if (index>=16.5)
{
}

//printf ("index number:  %.3f \n", index);

// printf ("L: %.2f \n", L(letters, words));
//printf ("S: %.2f \n", S(words, sent));
//printf ("letters: %i \n",letters);
//printf ("words: %i \n", words);
//printf ("sentences: %i \n", sent);
}

float L (int a, int b)
{
return (a * 100)/b;
}

float S (int x, int y)
{
return (y*100)/x;
}
``````

Can someone help me out?