I coded this solution myself, but I really can't figure out where I did wrong, I've spent days on this, and I would really appreciate any help!! Please, 😭

    #include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>


int count_letters(string text);
int count_words(string text);
int count_sentences(string text);
int index(string text);

int main(void)
{

    // getting user imput
    string text = get_string("Text: ");


    //show the number of letters in the text
    int countL = count_letters(text);


    //show the number of words in the text
    int countW = count_words(text);


    //show the number of sentences in the text
    int countS = count_sentences(text);


    //Grade Index Calculation (index = 0.0588 * L - 0.296 * S - 15.8)
    // L is average number of letter in 100 words (countL/countW * 100)
    // S is average number of sentence in 100 words (countS/countW * 100)
    int index = rintf(0.0588 * (countL / countW * 100) - 0.296 * (countS / countW * 100) - 15.8);
    // Situation when the index is lower than 1 and higher than 16+
    if (index < 1)
    {
        printf("Before Grade 1\n");
    }
    else if (index > 16)
    {
        printf("Grade 16+\n");
    }
    else
    {
        printf("Grade %i\n", index);
    }


}


int count_letters(string text)
    // to count the letters in the text
{
    int countL = 0;

    for (int i = 0, n = strlen(text); i < n; i++)
    {
        // if the alphabets between a-z (97->122) and A-Z (65->90)
        if ((text[i] >= 97 && text[i] <= 122) || (text[i] >= 65 && text[i] <= 90))
        {
            countL++;
        }
    }
    return countL;
}


int count_words(string text)
    // to count the words in the text
{
    int countW = 1;

    for (int i = 0, n = strlen(text); i < n; i++)
    {
        if (text[i] == 32)
        {
            countW++;
        }
    }
    return countW;
}


int count_sentences(string text)
    // to count the sentences in the word
{
    int countS = 0;

    for (int i = 0, n = strlen(text); i < n; i++)
    {
        if (text[i] == 46 || text[i] == 33 || text[i] == 63)
        {
            countS++;
        }
    }
    return countS;
}