Skip to main content
2 votes

Can't compile readability in cs50 IDE

I found that when following the instructions to create readability, the newly created tab "readability.c" has a red dot, and when clicked, it prompted me to save. Once saved, it should work. Hope ...
dragoogm's user avatar
2 votes
Accepted

Pset2 Readability test fail "complex single sentence" Grade 9 instead of Grade 8

What is happening there, is that you did your word count asuming that the next caracter would be alphabetical, here: al = isalpha(text[i + 1]);, but in this case, the next caracter are quotation marks ...
Tritum's user avatar
  • 1,571
2 votes

Readability check50 error

Did you notice that your code includes a colon after the word grade but check50 results don't? ;-) The lesson here is that program specs are to be followed exactly and precisely. Close or similar ...
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

Failure in Readability code

Pretty sure you meant isalnum. But shouldn't it be isalpha?
Blauelf's user avatar
  • 21k
2 votes
Accepted

pset1 problem set 2 readability

One of the hidden lessons of this pset is to teach the impact of integers and floats on calculations. Look at the following code: float l = (100 * n_let) / n_words; Each of the 3 numbers involved in ...
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

Readability lab: Counting letters

When you call strlen(), the function returns the number of letters, numbers, special characters etc. present in the argument. Additionally strlen() includes spaces. According to the instructions: You ...
Axolotl's user avatar
  • 51
2 votes

Readability CS50

Let me guess. The answers are sometimes right but sometimes off by 1? Look at these lines of code: //Calculate parameters and apply formula float L = 100.0 * (letters / words); float S = 100.0 * (...
Cliff B's user avatar
  • 69.3k
1 vote

Readability assignment, getting "Segmentation fault" message

Have a look at your evaluation condition for your loop: i += 1, n The net result of this condition is simply that i will get incremented by 1 each loop. The comma operator has the lowest precedence ...
Sentox's user avatar
  • 950
1 vote
Accepted

Readability CS50 Not counting the spaces

string input = get_string("Text:"); //getting input from the user int len = strlen(input); //determining the length of the string int space = 0; //declaring a variable to count whitespaces ...
Crisp_Coder99's user avatar
1 vote

Pset 2 - Readability -> Wrong grade

There are several problems. First, the word count is off by 1. Hint: is the code actually reading the end of string marker? Second, and most important, look at the calculations: float L = ...
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

pset 2 Readability Segmentation Fault

the issue is the condition you wrote inside the for loop for i (s[i] != 0 || s[i] != 1 ). you need to set a limit for i (when will the for loop terminate ? = when will the i stop increasing by 1?). ...
andream's user avatar
  • 109
1 vote

Pset2 Readability error with "else" statement

if/else is binary. true/false. An If cannot have two else clauses. It needs an else if to add additional conditions, as described here. [The page is for C++, but the lesson is valid in C]
DinoCoderSaurus's user avatar
1 vote
Accepted

What am I missing ? (pset2, readability)

the reason that your program is not working is because you are decrementing words with each question mark and exclamation point. If you remove words--; from your program, it works correctly! By the ...
AWTom's user avatar
  • 165
1 vote
Accepted

Fatal error "segmentation fault" when trying to run program

isalpha() expects a char, not a char *. You could dereference str using str[0], str[1] and so on. You can figure out which line of code is causing the segmentation fault by first clicking to the left ...
AWTom's user avatar
  • 165
1 vote

Week 2 Readability Letter Count

Hint: The function isalpha(), along with it's cousins like isspace() and ispunct(), etc., are your friends. ;-)
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

Someone familiarized with pset2's Readability. I'm stuck here

Syntax error. You just need to change it to the correct syntax. do { ... } while(isalpha(n)); The isalpha() function takes a parameter (inside the parentheses). That's what will be checked ...
Cliff B's user avatar
  • 69.3k
1 vote

Readability counting letters advice

First, there's no semicolon after return. But, that's a moot point. The return statement will cause the program to terminate immediately. It needs to be the last line in the program, before the last ...
Cliff B's user avatar
  • 69.3k
1 vote

Readability counting letters advice

I am unfamiliar with the exact problem you are working on, but one thing I see right away is that your for loop doesn't go anywhere - you say for(int i = 0; i > 0; i++) but then don't have ...
user29490's user avatar
1 vote

Pset 2 Readability

count_letters is a function. count_letters("Some text") is an int. You've got the %i flag in your printf statement, so you need an int as the second argument. That's why it's not compiling. ...
Llenk's user avatar
  • 744
1 vote

PSET2 Readability - tests no passing

From man ispunct: ispunct() checks for any printable character which is not a space or an alphanumeric character. This if (ispunct(txt[i])) will be true for a whole host of characters that are not .,...
DinoCoderSaurus's user avatar
1 vote

Why doesnt this code function?

The code doesn't work because num_letters is 0. The for loop will never run. In fact, it won't compile either because i and len are not created/defined before attempting to use them.
Cliff B's user avatar
  • 69.3k
1 vote

Having problems producung the correct result using the text extracts provided by CS%). I cant see where it goes wrong when finding the correct grade

float L = (letters / words)*100; float S = (sentences / words)*100; In this code, letters, words, and sentences are all ints, so when you divide them, the result rounds down. For the Harry Potter ...
Llenk's user avatar
  • 744
1 vote
Accepted

Incompatible pointer to integer conversion passing 'int on functions

You are not saving the value from your functions. What you're doing is the you call the function then the function counts the sentences and returns the count but your not assigning that return value ...
Ojou Nii's user avatar
  • 731
1 vote
Accepted

Copying an array (string) to new array after light mutating (pset2 readability)

It just so happens that the memory allocated to letter_box here char *letter_box = (char*)malloc(strlen(text+1)); is all nulls (ie \0). Since the if loop will not change any non-alpha character (...
DinoCoderSaurus's user avatar
1 vote

pset2 readability. cannot compile although int is declared and code is complete. could someone please look into?

The variables that you create in the for loops only exist within that for loop. You can use the result of a certain iteration of a for loop by eg: including an if function within the for loop to pick ...
Johann's user avatar
  • 21
1 vote
Accepted

pset2 readability. cannot compile although int is declared and code is complete. could someone please look into?

It's a scope problem: When you declare a variable inside a 'for' loop or a function, it only will be available until the loop/function ends. For example in your for loop: for(int i=0;text[i]!='\0';i++)...
Tritum's user avatar
  • 1,571
1 vote
Accepted

Why is my (readability.c) file in ~/.c9/metadata/environment/readability/ instead of ~/readability?

Press Ctrl+S (Windows) or Command + S (MacOS) to save the file. It will let you choose which directory you want to use.
Trung Nguyen's user avatar
1 vote

PSET2 Readability, most of my code works as expected, but one passage provided below

isalnum has no place here. isalpha checks for letters. Shouldn't matter as we have no digits. The word count is overcomplicated. Per problem specification, anything separated by spaces should be ...
Blauelf's user avatar
  • 21k
1 vote
Accepted

Readability program printing the whole sequence of a counted letter/number/word, rather than just the sum

The printf executes for every i because it is inside the for loop. If it should only execute when the for loop is complete, it needs to be outside the block (ie after the closing }).
DinoCoderSaurus's user avatar
1 vote
Accepted

CS50 Readability - Inconsistency in results

First, L and S should be floating point variables, using type float or double (either would work here). Then, the computation should be using floating point division. Integer division truncates the ...
Blauelf's user avatar
  • 21k

Only top scored, non community-wiki answers of a minimum length are eligible