Skip to main content

Questions tagged [credit]

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

Filter by
Sorted by
Tagged with
3 votes
2 answers
13k 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 ...
Arun Suresh's user avatar
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 ...
Prateek Pande's user avatar
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....
Caleb Bickford's user avatar
2 votes
1 answer
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, ...
Trevor Lim's user avatar
1 vote
2 answers
430 views

pset1 credit, need advice

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 ...
Daniel Böhme's user avatar
1 vote
4 answers
1k 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 ...
Arun Suresh's user avatar
1 vote
1 answer
635 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 ...
smajli's user avatar
  • 163
1 vote
3 answers
144 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 ...
KeleosWilliam's user avatar
1 vote
2 answers
616 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 ...
Julian Colombo's user avatar
1 vote
1 answer
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 ...
Jeremy Francis Webb's user avatar
1 vote
1 answer
40 views

CS50x PSET1 Credit <class 'pexpect.exceptions.EOF'>

So regarding Pset 1 Credit, I'm having this issue with Check50 My code identifies the card, but there's some error when input given at shorter length: My code are the following: #include <cs50.h&...
Blacov.'s user avatar
  • 11
1 vote
1 answer
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? ...
user avatar
1 vote
2 answers
165 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 ...
Rakshith Sridharan's user avatar
1 vote
1 answer
240 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?
RavanaNiK's user avatar
1 vote
1 answer
52 views

Credit : the checksum is correct for <10 digits, but for14,15,16 digits getting negative checksum

The checksum is correct for less than 10 digits but for 14-16 digits it is coming back negative. What am I doing wrong? #include <cs50.h> #include <stdio.h> #include <math.h> int ...
Parth Munjal's user avatar
1 vote
1 answer
333 views

problem with credit with this numbers (369421438430814 & 5673598276138003)

I just finished solving the credit problem and regularly used check50 to see my results, and then this happened. check50 sees that these numbers : 369421438430814 5673598276138003 are invalid, even ...
Yassen Redwan's user avatar
1 vote
1 answer
9k 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 ...
KeleosWilliam's user avatar
1 vote
1 answer
103 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 "...
TETRAD's user avatar
  • 13
1 vote
2 answers
96 views

Problem With Check50 for problem set "Credit"

I'm currently working on week 6 python and the problem sets are the same to that of pset 1 just with python instead of C. So when I decided to write it I saw that my code in C was extremely bad so I ...
Calapsy's user avatar
  • 13
1 vote
1 answer
49 views

CheckSum in credit pset1

as in the code given below i want to multiply 1 by 2 then delete it and so on but i don't how to do that i made the first steps to delete the last number by using %10 then show it with the /10 i hope ...
Ahmed Hussien's user avatar
1 vote
1 answer
86 views

Week 1 - Problem concerning question on 'credit'

Consider: #include <cs50.h> #include <stdio.h> int main (void) { //User's Input long n = get_long("Number: "); int sum_of_odds = 0; int sum_of_evens = 0; ...
Felix Chen's user avatar
1 vote
1 answer
33 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 ...
 kittensyzygy's user avatar
1 vote
0 answers
787 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 ...
Cazadore's user avatar
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 ...
spell78's user avatar
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)...
Tori_T's user avatar
  • 1
0 votes
1 answer
2k 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 &...
Gloria Isedu's user avatar
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!
Mohamed Alaa El-Din Fathy's user avatar
0 votes
1 answer
710 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 ...
PXSOCS's user avatar
  • 7
0 votes
3 answers
1k 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 ...
Petar Popovic's user avatar
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 ...
Thomas Adrianus Vreugdenhil's user avatar
0 votes
2 answers
128 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 ...
Anon's user avatar
  • 5
0 votes
1 answer
199 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 ...
Grisu's user avatar
  • 3
0 votes
1 answer
586 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 &...
xbufu's user avatar
  • 107
0 votes
1 answer
207 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 ...
albertjlay's user avatar
0 votes
1 answer
2k 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 ...
yuniFlaminjo's user avatar
0 votes
1 answer
431 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 ...
Frank Agraz's user avatar
0 votes
1 answer
411 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;
Andrés Felipe López's user avatar
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&...
Mohamed Alaa El-Din Fathy's user avatar
0 votes
1 answer
30 views

Week 1 Credit, two visa cards #s not working

I've been stumped on Credit for a few weeks, I've learned a LOT in writing my code and I have fixed many errors. My code now passes all the checks except for these two errors and I cannot figure out ...
msx68010z80's user avatar
0 votes
1 answer
29 views

How to Solve : expected identifier or '('

here is my code: #include <stdio.h> #include <cs50.h> //Declaring User-Defined Functions int last_digit(int sum3); int main(void) { //Promting the user for credit card number ...
molearns's user avatar
0 votes
2 answers
48 views

pset1-credit I can't find the issue with my code

the program prints invalid for valid card I know that my mistake is probably really dumb, but I can't find it (sorry for bad english) #include <cs50.h> #include <stdio.h> int main(void) { ...
Hecos's user avatar
  • 3
0 votes
1 answer
41 views

pset1 credit 2023 , do while loop with arrays/intervals

#include <cs50.h> #include <stdio.h> int main(void) { long n; do { n = get_long("13 digits or at max 15, 16 card number: "); } while(n < ...
REJEN RJ's user avatar
0 votes
1 answer
40 views

there is a logical error I can't really catch up with

Output: Results for cs50/problems/2022/x/credit generated by check50 v3.3.7 :) credit.c exists :) credit.c compiles :) identifies 378282246310005 as AMEX :) identifies 371449635398431 as AMEX :) ...
thefriendlyg's user avatar
0 votes
1 answer
98 views

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

I've been trying to figure out what's wrong with my code. I used printf so I could confirm whether or not the value of N is correct but it's coming out as completely different as what I would expect ...
maira's user avatar
  • 1
0 votes
1 answer
145 views

Need help with the Credit Problem for Week 1

I have signed up for this year's CS50x, and I am stuck on the problem where we are meant to validate a credit card. The problem requires that we check the amount of digits, the first digits and use ...
Vedant 's user avatar
0 votes
1 answer
69 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 ...
Thom OM's user avatar
0 votes
1 answer
118 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 ...
Multiplify's user avatar
0 votes
1 answer
183 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 ...
PrimeBeat's user avatar
  • 137
0 votes
1 answer
107 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, ...
Bob Tan's user avatar
0 votes
1 answer
65 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 ...
FoundABetterName's user avatar