1

I am trying to complete problem set 2 for cs50 and I am having trouble fixing my program , can anyone tell me why?

#include <stdio.h>

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

int main(void)

{ string s = get_string("Text: "); int num_words, num_sentences, num_letters; num_words = num_sentences = num_letters = 0; for (int i = 0, len = strlen(s); i < len; i++) { if (isalpha(s[i])) num_letters++; if ((i == 0 && s[i] != ' ') || (i != len - 1 && s[i] == ' ' && s[i + 1] != ' ')) num_words++; if (s[i] == '.' || s[i] == '?' || s[i] == '!') num_sentences++; } float L = (num_letters / (float) num_words) * 100; float S = (num_sentences / (float) num_words) * 100; int index = round(0.588 * L - 0.296 * S - 15.8);

if (index < 1)
    printf("Before Grade 1\n");

else if (index >= 16)
    printf("Grade 16+\n");

else
    printf("Grade %i\n", index);

}

3 Answers 3

0

The "slug" refers to the command line argument supplied to cs50, not to anything in the code. The command from the spec is

check50 cs50/problems/2020/x/readability

Verify it is typed correctly (or copy/paste from the spec or from this post).

0

I got this similar error when the python file wasn't created properly in the directory.

0

Well just in case someone still runs into this, for me the solution was putting exactly the same route indicated, i changed 2022 to 2024 and it wouldn't work just for that reason. An also run the check50 right from the directory your code file is in, although you invoke it with a few directory levels above it.

You must log in to answer this question.

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