What means the outputs after running cs50 check?


I’m new in CS50. I ran cs50 check for correctness of project 2 (greedy). But I don’t understand the following outputs,

greedy.c exists
:slight_smile: greedy.c compiles
:frowning: input of 0.41 yields output of 4
\ expected output, but not “0.41\n4\n”
:frowning: input of 0.01 yields output of 1
\ expected output, but not “0.01\n1\n”
:frowning: input of 0.15 yields output of 2
\ expected output, but not “0.15\n2\n”
:frowning: input of 1.6 yields output of 7
\ expected output, but not “1.60\n7\n”
:frowning: input of 23 yields output of 92
\ expected output, but not “23.00\n92\n”
:frowning: input of 4.2 yields output of 18
\ expected output, but not “4.20\n22\n”
:slight_smile: rejects a negative input like -.1
:slight_smile: rejects a non-numeric input of “foo”
:slight_smile: rejects a non-numeric input of “”

Can somebody help me??


I’m not entirely sure what you’re referring to - I guess you’re using c9 for some kind of MOOC or other e-learning course, right? In case you have questions about the content of the course, you better reach out to their forum or community. Right now, you’re in the support forum of c9 (the development environment you’re using). If you have questions regarding programming or C in general, consider communities like Stack Overflow or probably some Reddit groups.

Nevertheless, regarding your output:

I don’t know the content of the file greedy.c nor do I have any knowledge about how your CS50 check works, but good news: your C code compiles, there are no error. Congrats.

CS50 check is testing your code for functional correctness, meaning: does your code return the correct value for a certain input. Like “Is 2+2=4? If yes, everything is fine, if no, then I’m very sad”. I assume you get the specifications from your course instructions.

The output tells you what is ok and what you have to fix. Good news: your code is handling incorrect input values (like non-numeric or negative values) correctly - you can see this in the last 3 lines.

However, you return the wrong values for positive numeric input. The output is expecting an output value of 4 if your input is 0.41. But you return “0.41\n4\n”. And 4 is not equal to “0.41\n4\n”, therefore the test fails. The cryptic “\n” is a special character that indicates a new line (basically hitting return on your keyboard).