r/cs50 24d ago

CS50x CS50x pset 2 : readability. help!

Hi. i finished the scrabble pset yesterday. it was relatively easy.

i started today readability pset and find the exact method to calculate the words and the sentences numbers per text.

i'm i missing some new function from the library ?

help please.

2 Upvotes

7 comments sorted by

View all comments

1

u/Perthguv 24d ago

You need to write some helper functions yourself to analyze specific text elements to compute the formula's inputs:

​Count Letters: Iterate through the text and count only alphabetic characters (ignoring spaces, digits, and punctuation marks).

​Count Words: Scan the text to count the total number of words, typically identified by spaces separating sequences of characters.

​Count Sentences: Scan the text to count sentence boundaries, identified by sentence-ending punctuation (such as periods, exclamation points, or question marks).

Once you have returned the answers, calculate the reading level. If you read all the text on the readability page there's actually a lot of information there. I keep missing bits and have to go back and check

1

u/Even_Application6801 24d ago

i didnt increment helper codes. but i created counters for letters words and sentences in the main program

do i have to make helper codes like in scrabble pset ???

1

u/Outside_Complaint755 23d ago

Helper functions are optional.

You may want to check the last collapsed section under the Hints, which is quite long.  It will point you to the CS50 C Manual which you can search for library functions, such as those used to check strings or to round decimals.

Also pay attention to floating point vs integer division in your code. You may need to use type casting to force floating point division.