## From problem set 2

`index = 0.0588 * L - 0.296 * S - 15.8`
`\$ ./readabilityText: Harry Potter was a highly unusual boy in many ways. For one thing, he hated the summer holidays more than any other time of year. For another, he really wanted to do his homework, but was forced to do it in secret, in the dead of the night. And he also happened to be a wizard.Grade 5`
`// Ask user for text input// Calculate and store the number of letters// Calculate and store the number of words// Calculate and store the number of sentences// Apply the formula// Print grade as specified`
`#include <stdio.h>#include <cs50.h>#include <math.h>#include <ctype.h>// Prototype functionsint countLetters(string text);int countWords(string text);int countSentences(string text);int colemanIndex(int l, int w, int s);void printGrade(int index);int main(void){    string text = get_string("Text: ");    int l = countLetters(text);    int w = countWords(text);    int s = countSentences(text);    int index = colemanIndex(l, w, s);        printGrade(index);}int countLetters(string text){    return false;}int countWords(string text){    return false;}int countSentences(string text){    return false;}int colemanIndex(int l, int w, int s){    return false;}void printGrade(int index){    }`
`int countLetters(string text){    int count = 0;    for (int i = 0; text[i] != '\0'; i++)    {        if (isalpha(text[i]) > 0)        {            count++;        }    }    printf("%d Letters\n", count);    return count;}`
`~/pset2/readability/ \$ ./readabilityText: abcd efgh!8 Letters`
`int countWords(string text){    int count = 1;    for (int i = 0; text[i] != '\0'; i++)    {        if (text[i] == ' ')        {            count++;        }    }    printf("%d Words\n", count);    return count;}`
`int countSentences(string text){    int count =0;    for (int i = 0; text[i] != '\0'; i++)    {        if (text[i] == '.' || text[i] == '!' || text[i] == '?')        {            count++;        }    }    printf("%d Sentences\n", count);    return count;}`
`Text: abcd efgh! ijkl mnop. qrst uvxw?24 Letters6 Words3 Sentences`
`#include <stdio.h>#include <cs50.h>#include <math.h>#include <ctype.h>// Prototype functionsint counters(string text);void printGrade(int);int colemanIndex(int, int, int);int l, w, s, index;int main(void){    string text = get_string("Text: ");    counters(text);    colemanIndex(l, w, s);    printGrade(index);}int counters(string text){    int letters = 0;    int words = 1;    int sentences = 0;        for (int i = 0; text[i] != '\0'; i++)    {        if (isalpha(text[i]) > 0)        {            letters++;        }        if (text[i] == ' ')        {            words++;        }        if (text[i] == '.' || text[i] == '!' || text[i] == '?')        {            sentences++;        }    }    return l = letters, w = words, s = sentences;}int colemanIndex(int a, int b, int c){    return false;}void printGrade(int grade){    }`
`returnindex = round(0.0588*(a/((float)b/100))-0.296*(c/((float)b/100))-15.8);`
`void printGrade(int grade){    if (grade < 1)    {        printf("Before Grade 1\n");    }    else if (grade >= 16)    {        printf("Grade 16+\n");    }    else    {        printf("Grade %i\n", grade);    }}`
`Results generated by style50 v2.7.4Looks good!Results for cs50/problems/2020/x/readability generated by check50 v3.1.2:) readability.c exists:) readability.c compiles:) handles single sentence with multiple words:) handles punctuation within a single sentence:) handles more complex single sentence:) handles multiple sentences:) handles multiple more complex sentences:) handles longer passages:) handles questions in passage:) handles reading level before Grade 1:) handles reading level at Grade 16+`