Questions tagged [credit]

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

37 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
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 ...
0
votes
0answers
29 views

CS50 Pset Credit

After working on this problem for 5+ hours I was able to get the code working. After I summitted it, I looked at other peoples solutions, and most of them were very different than mine. Is the style ...
0
votes
1answer
27 views

Week 1 - Problem concerning question on 'credit'

#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; int count = ...
0
votes
1answer
28 views

CS50 problem set 1 CREDIT works sometime but not always

I am very new at coding and taking CS50. I am currently working on the credit problem in week 1. I finished coding but when I ran check 50 my code only seemed to work for some of the card numbers and ...
0
votes
1answer
26 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 ...
0
votes
1answer
31 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 ...
0
votes
1answer
24 views

Recalling the function for output changes the input

#include <stdio.h> #include <cs50.h> #include <math.h> int procedure (int array[] , int length); int input_length ( long input ); int main (void) { long card = get_long("...
0
votes
0answers
24 views

PSET6 Credit Regex Error

I have attempted to use regex matching to solve the credit problem, but I am encountering the problem of syntax error when trying to run my code. The regex.match function I tried to use was found from ...
0
votes
1answer
68 views

My do-while loop does not work

do { number = get_long_long("What is your credit card number? "); } while((number < 1000000000000) || (number >= 10000000000000000)); This loop is not accepting inputs. I do not ...
0
votes
1answer
40 views

Pset1 Credit - Why is my code bypassing the Floor function inside If statement?

Here's my code- int f_1 = floor(N / 1000000000000000); int f_2 = floor(N / 1000000000000); int f_3 = floor(N / 100000000000000); int f_4 = floor(N / 10000000000000); if (...
0
votes
1answer
62 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
21 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
1answer
31 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
56 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
23 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
63 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]= ...
0
votes
0answers
85 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
80 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
60 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
2answers
102 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
0answers
78 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
38 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
58 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 ...
0
votes
1answer
38 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
90 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
70 views

Pset1 valid visa number as invalid

I built the first part to check whether a number is a valid AMEX number and used the same logic to check for Visa number but the codes don't seem to work as I tried with several valid visa numbers and ...
0
votes
1answer
269 views

pset1 credit assignment

I assume anyone looking at this question knows the assignment but to recap I need to write a program that will identify different CC#s—AMEX, MC, VISA, or Invalid. Since all these CCs range from 13-16 ...
0
votes
2answers
59 views

Why does this code sometimes give me a different sum when i run it for the same cc number?

I'm working on the credit problem in pset1, and this is only part of what should be done. All I'm trying to do here is to multiply every other number (from the cc number entered by the user) by two, ...
0
votes
1answer
255 views

RE: Credit in PSET1

I have come up with, what seems to me, to be a logical walkthrough of the CREDIT problem (after banging my head against a wall for too long) - but the code does not make sense to the compiler. And I ...
0
votes
1answer
116 views

Problem with my credit.c code

My credit.c code keeps inserting huge numbers in my array for seemingly no apparent reason. For example the user enters 45231 for the credit card number, the beginning of the array is fine and ...
0
votes
1answer
583 views

pset 1 credit.c

I started with the credit card case but I am lost I wrote this till now I want some help to know what to do next of course not giving the whole thing because this is the purpose of the course... ...
0
votes
0answers
99 views

Need Coding style help - pset1 credit.c - (style50 failed to parse, feels and looks messy)

Style50 fails to even parse the code and it feels messy and cluttered. Need coding style pointers. Check50 passes. Trying to get the most out of this course, not just fumble through. What is wrong, ...
0
votes
0answers
110 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
0answers
166 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
0answers
258 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
1answer
279 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
0answers
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 ...