1
vote
I'm getting a floating point exception error in the credit code but I definitely haven't divided by 0
Found an answer!
The reason was an overflow, since the condition (n % i) <= n would be true upto infinity and long long i would keep being multiplied by 100 until even long long cannot hold the ...
1
vote
I don't what number means in PRIME/LAB1
In the code above, "number" is simply a variable name. It could easily have been "my_number" or "a_possible_prime" or even "fred" for that matter. The word &...
1
vote
Accepted
pset 1 mario style
The bottom line is that style50 is upset about all the inconsistent indentations across the program. On those two lines, it's just having trouble expressing it.
If this answers your question, please ...
1
vote
Accepted
CS50 Lab 1: Population Growth
first time posting here so pardon me if I don't have the right style. ;)
Your start- and endSize prompts are perfectly fine. Though, the specific task does allow for a startsize greater or equal to 9. ...
1
vote
Accepted
there is a logical error I can't really catch up with
Two questions.
What happens when an invalid number has the correct number of digits but doesn't pass the tests for any of the credit cards? Where does the code say it is invalid?
When a card is ...
1
vote
Accepted
In my CS50 mario program I'm getting an error which shouldn't be happening (C)
You are close, but there are a few errors. I copied and ran your code, and it wasn't outputting the pyramids as they were meant to. I would encourage you to test out your code in the terminal on your ...
1
vote
Problem with check50's result for pset1 mario less
The problem is the leading spaces on each line. This code will print 6 leading spaces on the first line no matter what. This is incorrect.
You could say that your code is simply printing the top h ...
1
vote
am stuck at calculating quarters in the greedy algorithms
In the distribution code they give you, they already send the remainder into the next function. You just need to write the function and return the value.
for example,
1
vote
Accepted
am stuck at calculating quarters in the greedy algorithms
There are a couple of common approaches to this. One uses a loop, the other doesn't. Your approach used part of both but doesn't produce useful info.
Applying the modulo operator will give you the ...
1
vote
Accepted
how can i get for it reprompt if the user types negative integer or number more 8 . my code does the oppoiste of what i want it to do how do reprompt
Think negatively!
Look at the test that the code is doing:
while(n <= 8 && n >= 1 )
This checks that n is in the range that is valid. You want the loop to repeat if it isn't in the ...
1
vote
Accepted
Dealing with pset1's "credit" problem
It's a problem with the for statement setup. Look at the statement:
for(int i = 0; i <= digit_number; i + 2)
The increment clause i + 2 isn't properly written. This takes the value in i and adds ...
1
vote
Accepted
1
vote
Credit.c is my nemesis
I got you, man. A little more experience with programming and you'll get there. Try including math.h and using some of its methods for counting and sorting through the digits. Here's my code as an ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pset1 × 1180mario × 360
greedy × 223
credit × 96
cs50x × 90
check50 × 80
cash × 78
c × 59
error × 39
mario.less × 28
cs50-pset1 × 21
water × 17
hacker1 × 16
water.c × 16
cash.c × 16
pyramid × 15
round × 14
credit.c × 14
pset1-credit × 14
for-loop × 13
appliance × 12
loop × 12
less × 12
cs50-ide × 11
help × 11