Hot answers tagged

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 ...
Certified Bibliophile's user avatar
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 &...
Cliff B's user avatar
  • 67.4k
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 ...
Cliff B's user avatar
  • 67.4k
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. ...
SindreV's user avatar
  • 26
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 ...
Cliff B's user avatar
  • 67.4k
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 ...
Jacqueline Des Rosiers's user avatar
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 ...
Cliff B's user avatar
  • 67.4k
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,
DJshelfmushroom's user avatar
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 ...
Cliff B's user avatar
  • 67.4k
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 ...
Cliff B's user avatar
  • 67.4k
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 ...
Cliff B's user avatar
  • 67.4k
1 vote
Accepted

tilde ~ not showing in ssh set up

Problem solved! I have replaced the tilde by a dot.
Maria's user avatar
  • 21
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 ...
Adam Wiley's user avatar

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