All Questions
20 questions
0
votes
0
answers
111
views
CS50 PSET 1 Hacker Bad Credit
With this code, I want to "Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products' digits together"get the ".
I don't get the correct results, ...
0
votes
0
answers
170
views
CS50: Bad Credit - pset1 hacker1: Program compiling but not executing
the following code for CS50's hacker edition Bad Credit is compiling but is not executing. Would really appreciate a review:
#include<stdio.h>
#include<cs50.h>
#include<math.h>
// ...
0
votes
1
answer
173
views
Pset1 Hacker Edition, Bad Credit "INVALID" Result!
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
long long n;
int nDigits;
long long k1, k2, k3, k4, k5, k6, k7,k8,k9,k10,k11,k12,k13,k14,k15,k16;...
0
votes
0
answers
260
views
Pset1, Hacker1,Credit.C, error while converting long long into an array
TL;DR Why does METHOD2 below work and not METHOD1??
I'll preface this with saying that after hours of trial and error, I got the code to work. However, I am still VERY CONFUSED as to why one method ...
0
votes
1
answer
298
views
Hacker pset1 credit.c always gives invalid?
I tried to attempt the credit.c problem. My code is as follows:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
#include <string.h>
int main(void)
{
printf("Please ...
0
votes
2
answers
241
views
credit.c frustration
Im considering skipping :( I dont really understand why it always prints INVALID4....
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main (void)
{
//Initialize a ...
0
votes
1
answer
99
views
credit.c help too debug please
Well i tried to debug it, by giving each INVALID a number, but i keep getting invalid 4, i think it is in the sum of array, but can someone look for the bug, i am just getting stressed out...
#...
-1
votes
1
answer
99
views
Why isnt my program working? credit.c
Well I decided to make the credit.c program, and I did, I started debugging and so until it compiled. But it always outputs INVALID and I can´t find out why, so this is my code:
#include <stdio.h&...
0
votes
1
answer
2k
views
Credit GetLongLong Issue
I'm having issues using the GetLongLong function. For some reason the output I get doesn't match the input I put in. Here, is my code.
#include <studio.h>
#include <cs50.h>
int main(void)...
0
votes
1
answer
186
views
Processing the separated digits using Luhn's Algorithim
My code compiles and runs. Separating out the required numbers also works. The problem in my output seems to start at the processing of Luhn's Algorithim. The section of below code processes the ...
0
votes
1
answer
38
views
Infinite looping
Credit PSET 1 Hacker:
The below code compiles and executes but in an infinite loop. I've tried writing the while condition a few different ways, but it seems to end up the same. I can get the ...
0
votes
2
answers
26k
views
How to convert the digits of a number into elements of array?
For example in pset1 hacker edition program asks user to input the number of credit card.
Imagine that a digits are: 1234567890
So can anyone tell me does it possible to convert this number into ...
0
votes
0
answers
122
views
hacker credit expected output
I'm getting that dreaded "expected output" error when running check50. Thing is, I don't have an added newline \n in my code. The actual output sure appears to be identical to what the checker was ...
3
votes
1
answer
193k
views
Why do I get the "invalid operands to binary expression" error?
While trying to solve credit, I get the following error
rem and number1 are declared as long and even if I change them to int, I still get the same error.
Please provide a solution and explain what ...
0
votes
2
answers
699
views
errors I cant understand in credit.c can anyone explain?
I am taking the number as a string(n) and then trying to convert the string into ints to add them like this:
else if(strlen(n)==15 && (n[1]==3&&(n[2]==4||n[2]==7)))
{
for(i=14;i&...
0
votes
1
answer
63
views
Code Debugging: Help?
Looking for some debugging help. I moved printf statements in and out of the code to see where the problem was coming from. I know that everything prior to this is correct and that the loop executes ...
0
votes
1
answer
87
views
Is it bad to use an ellipsis to handle a range of values in one case of a switch statement?
I was hoping to use a switch statement for the printf("CARD_NAME"); part of my code, and was wondering if it was bad style/practice to use ... like below? The examples from class all show to use case ...
0
votes
1
answer
138
views
credit.c project in hacker1 I keep having this error?
While trying to compile the codes uploaded I keep having this error which I couldn't understand!
0
votes
1
answer
188
views
Why is the last digit of my credit card number wrong in hacker1?
I was working on the hacker version of pset1 and I was using a for loop to grab the values of every single individual number (in CC#) and transfer it to an array. The for loop works fine, except that ...
3
votes
1
answer
379
views
Why Does credit Fail Passing check50 Tests?
When I input the credit card numbers that check50 inputs in its tests to my program myself, It correctly identifies the numbers as expected. However, when I run check50, it's not identifying correctly....