Questions tagged [credit]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
0
votes
1answer
21 views

pset1 credit: I am unable to identify what's wrong in the logic of my code?

Kindly tell me what mistake have I made in this program? pset1 Credit: (my code) https://pastebin.pl/view/5646dbf1
0
votes
0answers
22 views

credit pset1 bruteforcing doesn't work

I was trying out credit and tried to write a code for all 15 digit cards so if a AMEX card exists it should work in theory. However even with valid cards I'm getting the input invalid. I have not ...
0
votes
0answers
10 views

Why is my credit.c not outputing correct ans?

#include <math.h> #include <stdio.h> #include <stdbool.h> short unsigned int numlen(unsigned long long n); void isValidCC(unsigned long long int n); int main(void) { unsigned ...
0
votes
2answers
37 views

Can anyone help me troubleshoot my code for the CS50 Credit problem? (**not trying to cheat, just need some help!)

This is the code I have written in c for the cs50 credit pset 1 problem. I am checking the length of numbers entered, and the first digits (AMEX 15 digits, starts with 34 or 37; MC 16 digits, starts ...
0
votes
1answer
25 views

trouble summing the sides on credit

I have made it to the point it separates every digit into two sides so as to have two different sums, but then It gives me the wrong value of the sum. I'm pretty sure there is a bug in therms of it ...
0
votes
1answer
43 views

Question about Pset1 - credit

I had work on the credit for 3 hours, and I had reach to most of the function - and I checked that the number received from: Luhn (a) last digit(c) and digit count (cc) are right by using ...
0
votes
1answer
34 views

PSet1 Credit Invalid VISA that shows as Valid. My checksum must be wrong but dont know why

*/Here is the error I get: :( identifies 4111111111111113 as INVALID expected "INVALID\n", not "VISA\n" :( identifies 4222222222223 as INVALID expected "INVALID\n", not &...
0
votes
1answer
42 views

PSET6 Credit - checksum not giving the correct number

list1 = list(input("Number: ").strip()) even_count, odd_count, count = 0, 0, 0 # if the length is even if len(list1)%2 == 0: # iterating each number in list for num in list1: ...
0
votes
2answers
48 views

PSET 1 Credit; Sometimes Check50 works and other times it doesn't

Why does Check50 work for certain credit numbers and not others? I ran debug and found that for some credit numbers and not others it may randomly be always one away from a multiple of 10 preventing ...
0
votes
1answer
18 views

Week 1 Credit; Not Creating Variable

I'm starting the week 1 credit problem, however, when trying to set together every second digit it simply does not print. Could you help me identify where I went wrong? Thanks! #include <stdio.h>...
0
votes
1answer
77 views

I keep getting “expected EOF” when I use check50

this is the message identifies 4111111111111113 as INVALID expected EOF, not "INVALID" this is the code #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
21 views

My code is not compiling

my code isn't compiling and i don't understand the error message #include <cs50.h> #include <stdio.h> #include <string.h> #include <stdlib.h> bool checksum(string credit); ...
0
votes
1answer
15 views

When I multiply my array by 2 it doesn't give expected value

Also, please when I try to add "firstnumsum", it doesn't give expected value and I don't know what to do. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
45 views

i don't know what's wrong with my code. Trying to convert from string to long

INPUT int main(void) { long long cardnumber, calc; string credit[0]; string nonnumeric; //long long calc = card number; int countcardcharacters = 0; long long c; //user input do { credit[0]= ...
1
vote
1answer
27 views

Making code neater: a way to reduce repeated logical operators?

For CS50 pset1 Credit I'm using repeated logical-OR operators (||) to work out the validity and card brand of a credit card number. When I evaluate the style of my code using style50 it says to insert ...
0
votes
1answer
46 views

How do you find the first digit of a long number?

I wrote the following code to try to find the first digit of a long number (this is for the CS50x "Credit" exercise), but it's not working. Any tips? // Conditions and relational operators #...
0
votes
1answer
31 views

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

I was almost finishing my code when I got stuck with a strange problem. I've asked a question a few hours ago and someone answered, so I manage to fix that issue. But unfortunelly I got stuck in ...
0
votes
1answer
20 views

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

So I coded the first lines of the Luhn's Algorithm and tried to print the values of some of my variables to be sure they were doing exactly what I want it. For my surprise they weren't. And I were ...
0
votes
1answer
71 views

PSET1 - Credit: Check50 says wrong what should be right

Someone with the same problem? I have a 16 digit number starting with a 4 and my code identifies it correct as VISA\n, but the check50 says it has to be INVALID\n. What could cause this strange ...
0
votes
0answers
77 views

I can't get the Luhn algorithm to run properly in my code

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardnumber = 0; //Prompt the user for the credit card number using get_long do { ...
0
votes
1answer
69 views

Need help (or idea) making the code looks cleaner. (PSET1/CREDIT)

My code passed pset1/credit but I still think the there must be a way to make my code looks cleaner and more impact. If you have any idea please criticize the code. Thank you in advance. #include <...
0
votes
1answer
53 views

HELP ME!! CS50 pset1 credit.c says INVALID but when I debug it says AMEX?

#include <stdio.h> #include <cs50.h> int main(void) { long long cc; //get user input for cc do { cc = get_long_long("Number: "); } while (cc <= 0); /...
0
votes
1answer
43 views

CS50 Credit - again a scope problem

I think I almost finished the credit problem set, however, I have another scope problem. I think it is really simple. After the checksum, the code is not working anymore. If I put extra braces by the ...
0
votes
2answers
83 views

Credit pS1: how to store the seperate digits and store them

Thank you for the answers. I think that I made some steps. The problem now is that I can't store the seperated digits. It only stores the last one in "remain". My other challenge is that seperating ...
0
votes
1answer
19 views

Scope problem - not print the test results

I have trouble with my scope (PS1, credit) I am using two while loops and to test the result, i print results in between. This code does not print the second printf. I think it is a scope problem but ...
0
votes
0answers
66 views

Stuck by problem set Credit, % operator

As a beginner I am stuck in de problem set Credit. Especially the % function is giving me trouble To better understand it, I tried to use the example of programming simplified to get the sum of digits....
0
votes
1answer
56 views

pset6 credit the sum is not end with zero and check count right how

the Luhn’s Algorithm in 378282246310005 = 48 and in 371449635398431 = 76 so how not INVALID it must end with zero so the two number must be INVALID
0
votes
1answer
65 views

Pset 1 Credit - trying to use count to solve the problem but returns 0

I am trying not to use Arrays to solve this problem. However, the answer keeps showing as 0. Can someone pls help to explain? Thanks a lot in advance! Below is the code: I am trying 1. get the ...
0
votes
0answers
27 views

what are questions about my code, the week1 credit assignment

#include <cs50.h> #include <stdio.h> int length(long long n); int lastdigit(long long n); int stay(long long n); int addmutiply(long long n); int odd(long long n); int digit2(long long n);...
0
votes
1answer
28 views

Check50 giving different results from the code I compiled in pset1

For Problem Set 1, I have the code as written below #include <cs50.h> #include <stdio.h> int card_length(long cNo); void luhn_algo(long lacno, int lacnolen); void finalPrint(int cardDet);...
0
votes
1answer
61 views

I am not getting the correct output when i enter David's card number in credit

This is my code: #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { int x, y, z, p, q, r, d, e; int k = 0; int s = 0; long A; long n = ...
1
vote
1answer
211 views

credit - Why this AMEX and MASTERCARD numbers are considered invalid?

I have compiled my version of credit, anyway check50 throws 2 fails during its check. Lines with numbers where it fails are: :( identifies 369421438430814 as INVALID expected "INVALID\n", not ...
0
votes
1answer
459 views

error: result of comparison against a string literal is unspecified (use strncmp instead) and Check50 showing error on credit problem

I've submitted my credit problem after testing with possible values and everything seems to work just fine as planned, except that I got some errors that certain numbers could not be tested as INVALID ...
0
votes
1answer
54 views

What is probably wrong in this while loop?

I'm getting positive integers from users. I used a do-while loop to check and validate that the user input is: 1. A positive integer. 2. The length (I.e size) is between 13 and 16 digits BUT NOT ...
1
vote
3answers
112 views

Why is this while loop generating errors

I'm trying to get a 15 or 16 digits numbers (integers) from users and then using a do while loop to check if the user entered a valid number, otherwise, they will be re-ask to enter the number. THE ...
0
votes
1answer
35 views

cant figure out whats wrong with my credit code

#include <stdio.h> #include <cs50.h> #include <string.h> int numlength(long num); int main(void) { long num; do { num=get_long("Number :") ; }while(num<0)...
0
votes
1answer
39 views

pset1:credit, multiplication problem

for some reason my program doesn't multiply (card_number % 10) * 2 for example when card_number % 10 = 6 the output is 6 instead of 12. for(int x = 0; card_number != 0; x++) { if (x % ...
0
votes
1answer
264 views

Pset 1: Credit problem - Checksum?

I'm having trouble with the checksum in the #credit problem. I have no clue on how to operate specific digits within the credit card number (specifically, multiplying the digits in the odd positions ...
1
vote
1answer
873 views

Pset6 credit python Problem

I try to convert my Credit Solution from C to Python now. But on Line 19 ( doubleCheck = ccNumber[i] * 2 ) i always get the error "TypeError: 'int' object is not subscriptable"! How can i fix this? ...
0
votes
1answer
87 views

Credit.c works, but not completely?

So I finished credit.c today and was trying out different numbers from the paypal website the course provided and got some unexpected results and don't know what to do with it. When I type in valid ...
0
votes
1answer
59 views

pset1 credit formula to extract digits keeps returning 0 (potential data type issue?)

Below is the block of code that i have issue with. I'm using this method to extract the digits: num[i] = (num % pow(10, i))/pow(10, i-1). The pow1 and pow2 variables print out correctly, but "digit" ...
0
votes
1answer
338 views

Can't use get_long_long();

So somehow I cant use the get_long_long(); function. It lets me declare the variable, but I cant get any user input for it. Here's my code: #include <stdio.h> #include <cs50.h> #include &...
1
vote
2answers
131 views

error at while loop cs50 Pset1 credit

I am getting an error at while loop it says error: '&&' within '||' [-Werror,-Wlogical-op-parentheses] while((credit % 10 >= 0) && (i < 15) || (i < 16)) here is my ...
0
votes
1answer
68 views

Credit.py Invalid Error

For Pset6 Sentimental/Credit, my code keeps showing a result of INVALID\n no matter what is passed in. Debug50 is not working in Python, so I was not able to work through the lines one by one. Any ...
0
votes
1answer
106 views

pset1 - problem with credit ..help plz

I spent so many hours and still can't figure the problem, any guidance would be appreciated.. I checked against all the paypal test numbers and got same response as the staff's execution, though I got ...
0
votes
1answer
105 views

pset1 - credit - if-else statement issue

I have written a (clumsy) solution to the credit pset1. However, the solution only works for "Mastercard" credit card numbers (i.e. 5555555555554444). For "Visa" and "Amex" my code does return the ...
1
vote
1answer
176 views

problem with pset6 python credit

Below is my code: [hidden code] output is: Enter the card number: 378282246310005 firstTwo 37; firstOne 3; cardlen 15 MASTERCARD note: it shows MASTERCARD instead of AmEx..Why?
0
votes
1answer
112 views

PSET1 - Credit Checksum Problem

{ long long l; do { l = get_long_long("Number: "); } while (l < 0); float count = 0; long long m = l; while( m != 0) { m /= 10; count+...
0
votes
1answer
77 views

pset1 credit working only in certain cases

So, this is probably not a good solution of the problem, but I hoped it would at least work, after struggling with it for quite some time. It made me happy to see it worked for the first number I ...
0
votes
1answer
160 views

PSET1 - Credit HELP

I am now working on the first part of credit, and is currently checking the validity of the number given. I separated it into two parts, one where I summed the doubled digits, and one where I summed ...