Questions tagged [credit]
153 questions
0
votes
0
answers
35
views
What do you think about my code here?
#include <cs50.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
long long credit_num;
credit_num = get_long_long("credit number: "...
0
votes
1
answer
30
views
For Loop to look through all values of an Array
So, I am learning C using cs50 and a problem I have run into is that although i have yet to learn about arrays, I need to use arrays for my problem set. I would really appreciate it if someone could ...
0
votes
1
answer
33
views
Getting "use of undeclared identifier" and can't solve it without ruining my code
i've been working on the mechanism to get every other number of the credit card number, and this is what i've come up with so far:
int get_credit(void);
int check_sum(int number, int a);
int ...
0
votes
1
answer
121
views
pset1:Credit (always outputs INVALID)
Whenever I input any card number into the program it outputs INVALID. I think the issue has something to do with not finding the first digits (int fdig) correctly because I used a print function ...
0
votes
1
answer
52
views
Output problem credit
Finished my credit problem, whit the code below, but when I check it with check50 everything fails despite the output on the terminal being correct when I check manually.
Code:
#include <cs50.h>
...
0
votes
2
answers
118
views
Pset1 credit, checksum value gives wrong value
I find myself stuck on credit. Can't figure out where the problem lies in my logic. Checksum gives 4 where it should give out 0. Ideas appreciated.
//calculate checksum value
int sum1, ...
0
votes
1
answer
150
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
1
answer
36
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
1
answer
46
views
I have to enter any letter to get the result
I am currently doing the problem set 1 credit in cs50 program. I managed to write the code. It's compiles fine however once I enter the credit card number it stops, i must type any letter to get the ...
0
votes
1
answer
89
views
PSET 1 Credit Card Checksum doesn't add up
I'm having my issues finding the right answer as this is non code related.
The checksum says: "If the total’s last digit is 0, the number is valid!"
This is a credit card number that is ...
0
votes
1
answer
113
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
1
answer
48
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
1
answer
88
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
0
answers
137
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
1
answer
47
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
1
answer
130
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
1
answer
213
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
1
answer
30
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
1
answer
97
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
1
answer
1k
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
0
answers
91
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
1
answer
107
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
1
answer
89
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
2
answers
191
views
Credit pS1: how to store the separate digits and store them
I have made some progress, but I can't store the separated digits. It only stores the last one in "remain". My other challenge is that separating the digits above 9 gives the result "0&...
0
votes
0
answers
115
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
1
answer
71
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
1
answer
70
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
1
answer
72
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
1
answer
48
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
1
answer
166
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
1
answer
133
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
1
answer
95
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
1
answer
81
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
1
answer
295
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
1
answer
276
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
1
answer
134
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
1
answer
129
views
Problem with credit.c
I have a problem with credit.c.
The program works when the user enter a numeric input but when someone enters a string, i don't know how to make that the program print "Number: " again. Instead of it ...
0
votes
1
answer
158
views
Problem with && and || operators in credit
Forgive me for the confusing syntax, I am new to coding. My question is simple. In my last statement, >> "else if (digits[15] == 5 (&&) digits[14] == 1 || digits[14] == 2 || digits[14] == 3 || ...
0
votes
1
answer
602
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
1
answer
222
views
pset1 - credit expected output, not a prompt for input when testing
I just started this course and have been enjoying it very much.
I complete pset1 credit with the following code.
But when I check my solutions, it always returns:
Has anyone encountered this?
:) ...
0
votes
1
answer
1k
views
Think my credit program is right. I think sample credit card numbers are wrong [duplicate]
NOTE : I AM USING STRING INSTEAD OF LONG LONG TO STORE CC.
:) credit.c exists
:) credit.c compiles
:) identifies 378282246310005 as AMEX
:) identifies 371449635398431 as AMEX
:) identifies ...
0
votes
0
answers
111
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
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
1
answer
483
views
credit.c code review
How come long long cannot handle this input? Further how is the arbitrary output computed?
What is the appropriate relational operator for <> a.k.a. within or between two values i.e. I am ...
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 ...
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 ...