0

When I submit my readability code check50 says:

Expected Output:
Before Grade 1
Actual Output:
Before Grade 1


Expected Output:
Grade 16+
Actual Output:
Grade 16+

Since my program outputs what is expected, I am not sure how to fix this.

int main(void)
{
    int i, letter = 0, word = 1, sent = 0;

    // prompt user for text

    string text = get_string("Text: ");

    // iterate text for calculations
    for (i = 0; text[i] != '\0'; i++)
    {
        if ((text[i] >= 'A' && text[i] <= 'Z') || (text[i] >= 'a' && text[i] <= 'z')) // count letters
        {
            letter++;
        }

        else if (text[i] == ' ')  // count words
        {
            word++;
        }

        else if (text[i] == '.' || text[i] == '!' || text[i] == '?')  // count sentances
        {
            sent++;
        }

    }
    float l = (100.00 / word) * letter;
    float s = (100.00 / word) * sent;

    float index = 0.0588 * l - 0.296 * s - 15.8;

    int grade = round(index);

    if (grade < 1)
    {
        printf("Before Grade 1");
    }
    else if (grade >= 16)
    {
        printf("Grade 16+");
    }
    else
    {
        printf("Grade %i\n", grade);
    }
    return 0;
}
1
  • Can you provide a screenshot of your check50 results? This might help us get the full picture as your question, understandably, doesn't give much to go on. – Robert S. Pratt Feb 10 at 18:13
0

I could not resolve this and so I rewrote the code from the beginning and it passed. May have just been a glitch in the file since I had rewritten it so many times trying to get it correct. New file, new code. No problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .