2 votes

error at while loop cs50 Pset1 credit

The compiler is actually giving a warning, but the compiler flags are set up to treat all warnings as errors. It's still best to eliminate all warnings. Here's the reason. For clarity, let's ...
Cliff B's user avatar
  • 67.4k
2 votes

Credit Problem: what does "number’s second-to-last digit" mean?

Agreed that the example used can be ambiguous. We have updated the AP Credit problem spec with a better example that makes it clear that you must start from the last digit (and the first number to be ...
curiouskiwi's user avatar
  • 18.5k
2 votes

Credit Problem: what does "number’s second-to-last digit" mean?

For the sake of discussion, let’s first underline every other digit, starting with the number’s second-to-last digit: 378282246310005 Second to last digit is the digit before the last digit, in ...
Cliff B's user avatar
  • 67.4k
2 votes
Accepted

Credit.c is my nemesis

Your counting loop destroys the number. Destroy a copy instead. And stack variables are not initialised by default, so you end up with some arbitrary data as the array isn't filled at all due to your ...
Blauelf's user avatar
  • 20.9k
1 vote

pset1 Credit: how to write it shorter

Edit to rephrase, I hope this one is ok with the admin. Operate on a copy of the number (so that you can use the number later for other things). Use a loop, can be a pretty simple while loop, and ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Credit task problem

One of the hidden lessons in the first few psets is to write to the specification exactly. That means that anything extra, missing or misplaced, including prompts, output, whitespace, line feeds, ...
Cliff B's user avatar
  • 67.4k
1 vote

credit.c I don't understand how to fix my code

It looks like you expect ^ to do exponentiation. It doesn't; it is the Bitwise XOR operator in C. You can use the pow function in the math library instead.
DinoCoderSaurus's user avatar
1 vote
Accepted

credit pset1 bruteforcing doesn't work

This is because you've overlooked an important piece of information provided with the explanation of Luhn's algorithm. It actually says in the algorithm to add the products' digits to the checksum and ...
iamakhilverma's user avatar
1 vote
Accepted

ProblemSet1 - Another Credit.c issue - Can't convert the floating value of my variables into an integer value

Having problems with this? temp_b /= (10 ^ 14); That would be because the ^ operator is not an exponent operator as it is in mathematics. It's the exclusive or operator. You might try a call to pow()....
Cliff B's user avatar
  • 67.4k
1 vote
Accepted

ProblemSet1 - Credit.c - Issues assigning the sum of the numbers on a variable

When you say number /= 10, you are actually reducing the number variable itself. So after counting and getting the value for count, the value of number is equal to zero
Oadeniran's user avatar
1 vote
Accepted

cs50 pset1 credit expected expression error

Look at the line in question: if(askPositiveLong >= 340000000000000 && askPositiveLong < 350000000000000) || (askPositiveLong >= 370000000000000 && askPositiveLong < ...
Cliff B's user avatar
  • 67.4k
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