I tried using debugger but could not figure out where I went wrong. please help
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <math.h>
int main(void)
{
int letters = 0, words = 0, sentences = 0;
string text = get_string("Enter text:\n");
for (int i = 0 ; text[i] != '\0'; 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] == ' ' || text[i] == '\n' || text[i] == '\t')
{
words++;
}
else if (text[i] == '.' || text[i] == '!' || text[i] == '?')
{
sentences++;
}
}
printf("Letters: %i\nWords: %i\nSentences: %i\n", letters, words, sentences);
float L = ((float) letters / (float) words) * 100;
printf("Average No. of letters: %f\n", L);
float S = ((float) sentences / (float) words) * 100;
printf("Average No. of sentences: %f\n", S);
float grade = (0.0588 * L) - (0.296 * S) - 15.8;
if (grade <= 16 && grade >= 0)
{
printf("Grade %i\n", (int) round(grade));
}
else if (grade > 16)
{
printf("Grade 16+\n");
}
else
{
printf("Before Grade 1\n");
}
}