# Questions tagged [credit]

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

138 questions
Filter by
Sorted by
Tagged with
10k views

### Finding the nth digit for credit card number

I'm having a hard time trying to find the 2nd to last digit of the user's credit card number, since that's the starting point for Luhn's algorithm. Is there a way to convert a long to an array and ...
126k 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 ...
359 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....
4k views

### Credit from CS50 2018 week 1 walkthrough

Hi i am a beginner and i have been trying to solve this set but with no avail. I tried to use what was taught in the first lesson and did search for some help online when i encounter errors. However, ...
411 views

I actually try to do the Credit Task back from pset1. So far i understand how the calculation for the checksum validation of the Credit Card Number works, and could do it on Paper. The Problem, i ...
964 views

### Finding the products' digit and adding them individually

Separating the products' digits and adding them up is giving me trouble. For example for this credit card number: (1234567), 12, 8, and 4 would be the result of multiplying every other digit by 2. How ...
336 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 ...
127 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 ...
5k views

### Pset 1 Credit Card ( help needed )

Update # attempt 2: I am not getting valid output, code complies fine. What am I missing? code follows: including cs.50 and stdio ( i don't think i need math ) bool checksum( long long cc); // for ...
2k 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? ...
144 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 ...
224 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?
471 views

### Credit.c is my nemesis

I have no experience programming, and English is not my first language so I'm struggling a lot with this particular problem. In "credit.c" you have to prompt the user for a credit card number and ...
80 views

### Incorrect mastercard number in pset1 [duplicate]

by lunh algoritm result of calculating 5105105105105100 will be 25 and it means that this card is invalid, but check50 output this: :( identifies 5105105105105100 as MASTERCARD expected "...
30 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 ...
706 views

### Every 2nd digit on Pset1 Credit problem: Tldr bolded

Im struggling with manipulating the string of numbers in the credit problem. I've figured out how to divide the initial input number by 10 (*100 each iteration) then mod % by 10 in order to access the ...
17k 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 ...
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)...
135 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!
870 views

### pset 1 credit.c invalid cards are valid by cs50

It was said that you can verify if the credit card number is valid by using Luhn’s algorithm. If you done mathematical operations right, after them, you know if the card is valid if the last digit in ...
239 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 ...
59 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 ...
365 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 &...
82 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 ...
408 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 &...
186 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 ...
1k views

### pset1 | error: invalid operands to binary expression ('long long *' and 'int')

Here are snippets of my code: long long card = get_long_long(); long long *FindLength = *card; while (FindLength != 0) { FindLength = FindLength / 10; counterCardLength++; } And ...
410 views

### Credit - Why Does it Fail Passing check50?

When sending my code to Check50, all the Credit Card checks go through ok but one: :( identifies 4062901840 as INVALID expected "INVALID\n", not "VISA\n" But doing the steps: 1) Multiply every ...
383 views

### I have problems applying Credit in python

I try to translate my code from c to python. I review the code several times and I think that is equal, but the program don't works despite in c works prefectly. This is my implementation: """Know ...
403 views

### long long to array, how did you do?

I want to know new ways to do it, this is my solution. arr[nccard - i] = (long long)(ccard / pow(10, i - 1)) % 10;
660 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&...
34 views

### credit pset1 cs50 sum while loop

I was doing the credit problem with the visa test card in the page: 4003600000000014 It passed that test, however in other tests it doesn't pass. I think it's a matter of the sum that it can't compute ...
61 views

### Credit Card Check

So I am on pset6 trying to implement the credit card check. I've already completed working through the numbers and am not having any issue with the actual algorithm. But for some reason my if ...
60 views

### Credit (Pset1) - Checksum problem

so I have a problem with the Credit exercise from pset1. I updated my code today after realizing that I didn't split up the digits of the product of the current digit in the card number and 2 and ...
46 views

### pset6 credit help with calculations in python

I am trying to convert my credit solution from C to python, but for some reason it is not working. Attached is my code and the problems from cs50 import get_int card, a, m, v = False, False, False, ...
48 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 ...
77 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 ...
74 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 ...
57 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: ...
25 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>...
37 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 ...
32 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 ...
47 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 ...
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 ...
68 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
69 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 = ...
344 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 ...
63 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" ...