2
votes
Stumped on PSET 1 Mario Less Comfortable
Looks like you have an extra for loop there, which will cause the entire thing to loop l times when that's probably not what you intended.
2
votes
Accepted
CS50 problem set 1 cash
Try printing out the value of cents after each calculation and think about the effect of integer division vs. regular division.
Does the code track BOTH the number of coins for each denomination AND ...
2
votes
Accepted
Hello world error
First of all, welcome to CS50! :)
To add to NullityNull's good advice, it looks to me like you probably have more than one copy of hello.c, probably in different directories. The one you are trying ...
2
votes
Hello world error
First, make sure you are in the same directory that the program is in and you can check if so by typing 'ls' into the console. Another thing to do is make sure you named the file 'hello.c'. that ...
2
votes
Accepted
cs50 Problem Set 1: Greedy. float 0.01 problem
Most of the problem is that no matter what you do, you keep putting the result back into change, a float. Floats have this nasty little problem that they don't store fractional parts of a number, the ...
1
vote
Accepted
problem set cash: why am I getting really high numbers in my return?
It looks to me like it's stuck in an infinite loop. Let's look at one of your functions.
int calculate_quarters(int cents)
{
int quarters;
while (cents >= 25)
{
quarters = (...
1
vote
Stumped on PSET 1 Mario Less Comfortable
in your code check the first for loop, why is the counter decreasing ?
why do you need 4 for loops?
to create the right aligned pyramid you need only 3 for loops.
external loop, to count from the ...
1
vote
Accepted
Nothing prints in Mario Problem
You have set up the while condition incorrectly.
Your do/while loop is this:
do
{
...
} while (h>=1 || h<=8);
You have essentially created an infinite loop. Think about the test ...
1
vote
Accepted
continue from 2018 to 2019
Have a look at your gradebook. I would expect that you don't have grades for Resize, Recover (both pset3 this year), Homepage (pset5) and the final project.
Is that what you are seeing? You will ...
1
vote
mario.c (comrfortable) error code
Much shorter alternative:
#include <stdio.h>
int main(void)
{
int n = 6;
char blocks[n];
memset(blocks,'#',n);
for(int i=0; i<n; ++i)
{
printf("%*.*s %.*s\n", ...
1
vote
mario.c (comrfortable) error code
:( handles a height of 1 correctly expected "# #\n", not " # #\n"
The last row (or the first/only in this case) should be left aligned. As well, there should be 2 spaces between the half-pyramids. ...
1
vote
Accepted
Stuck on Problem set 1! (greedy.c)
First of all, the problem with killed by the system is due to your program being stuck in an infinite loop.
When I get into such an issue it helps me to take out a pen and paper and follow the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
problem-set-1 × 17cs50x × 6
greedy × 4
cash × 4
mario.less × 3
problem × 2
pset1 × 1
c × 1
mario × 1
error × 1
for-loop × 1
variables × 1
cs50x2019 × 1
style50 × 1
float × 1
cs50x2018 × 1
cash.c × 1
conditions × 1
initializing × 1
helloworld × 1
return-value × 1
not-returning-cash × 1