Questions tagged [pset1-credit]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

pset1 credit.c file EMPTY?

this is my first question in this community. I just downloaded the zip file for pset1, problem credit (more comfortable) is the file actually empty ? could it be that I did something wrong? thank you ...
0
votes
1answer
13 views

Need Help, why does my debug50 show a correct result but when i run the program, thus it shows a wrong answer

Here's my code #include <cs50.h> #include <stdio.h> #include <math.h> //1:26:36 / 2:24:59 int main(void) { long n; int exc; do { n = get_long("Enter your ...
0
votes
1answer
21 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 ...
0
votes
1answer
20 views

CS50 Credit Pset problem- Code keeps looping back to ask for the credit card number

The following is my code for the Credit Pset from week 1 of CS50, it is not the complete solution to the problem (all the code does (rather is supposed to do) is for the user to enter a credit card ...
0
votes
1answer
23 views

Cs50 pset1 problem credit

I'm not able to take out the second digit of the credit number, how to do it for large numbers like 16 digit,15digit,14 digit?
0
votes
1answer
15 views

Credit problem: Opening parentheses not matched with closing

Though it might appear annoying, the program not compiling. To the best of my understanding, there is a closing parenthesis on line 37. Is it some cache related issue? https://drive.google.com/file/d/...
1
vote
1answer
41 views

Function in C: How to create

#include <stdio.h> #include <cs50.h> int main(void) { long creditcardno; do { creditcardno = get_long("enter"); } while (creditcardno < 0); } The above code accepts ...
0
votes
1answer
40 views

Could not find the following in the output: <class 'pexpect.exceptions.EOF'>

#include <stdio.h> #include <cs50.h> int main(void) { long creditcardno; do { creditcardno = get_long("enter"); if (creditcardno < 999999999999 || creditcardno ...
0
votes
1answer
92 views

Credit card problem: Unable to calculate the sum of entered credit card no

#include <stdio.h> #include <cs50.h> int main(void) { long creditcardno; do { creditcardno = get_long("enter"); } while (creditcardno < 1000000000000 || creditcardno > ...
0
votes
2answers
14 views

Unable to move to the next chunk of the problem

#include <stdio.h> #include <cs50.h> int main(void) { long creditcardno; do { creditcardno = get_long("enter"); } while (creditcardno < 1000000000000 || creditcardno > ...
1
vote
1answer
33 views

Pset1- Credit: Length of the number by continuously dividing by 10

// Get card number long n = get_long("Number: "); // Count length int i = 0; long cc = n; while (cc > 0) { cc = cc / 10; i++; } Source: https://medium.com/swlh/cs50-pset-1-credit-...
0
votes
1answer
23 views

Do-while code for long integer input

It is mentioned in the problem: American Express uses 15-digit numbers, MasterCard uses 16-digit numbers, and Visa uses 13- and 16-digit numbers. So with get_long, I perhaps need to restrict input ...
0
votes
1answer
41 views

Segmentation Fault for PSet1 Credit in CS50

first time posting. I swear I looked for answers in other segmentation fault questions already, but I am new to programming and to troubleshooting/researching effectively. My PSet1 program "...
0
votes
1answer
35 views

Pset1:credit - converting a long to a string causes a segfault?

I keep getting a segfault, and help50 doesn't help. A lot of head scratching an googling later, I think I've narrowed it down to: you can't convert a long to a string. Is that true? The code in ...
0
votes
1answer
28 views

PSET1 - credit ,not satisfying all test cases ,please help

These are the test cases which my code doesn't satisfy ,can someone please help me out as i have absolutely no idea why it is happening. Some tips or advice would be handy. Thank you in advance. :( ...
0
votes
1answer
41 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
29 views

Pset1 Credit- How should I proceed to add the sum of multiplied digits & further addition with remaining credit card numbers?

I can pretty much select the digits, multiply the digits by 2 & add the particular digits of the multiplied number. But as of now I can only print them not add them. I also have to add this sum to ...
0
votes
1answer
22 views

expected expression error in pset1 credit for loop

I am getting a error in the following line long checksum = (long) for (int i=1; i < 8; i=i+2) { if (checksum > 9) { (((long) 2*(credit_number % (long) ...
0
votes
2answers
93 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
157 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
34 views

Stuck with pset1 credit question. I don't know why I'm not able to get any "Valid" outputs when a valid card number is entered

#include <stdio.h> #include <cs50.h> #include <math.h> #include <stdlib.h> int main (void) { int count = 0; //Declare counter //Get input from user long number = get_long (&...
0
votes
1answer
63 views

trying to check second to last digit-- cs50 pset 1 #credit#

I am trying to understand the second to last digit thing, i think i have been coding wrong the whole time. take this example 45002136581 in the walk through the guy says we take 5 0 2 1 5 1. while i ...
0
votes
1answer
56 views

PSET 1 Credit AMEX

I've calculated the Luhn's algorithm for all the credit cards and it works fine. The only issue I have is that the American Express cards which are tested don't fulfill the Luhn's algorithm! This is ...
1
vote
1answer
87 views

cs50 pset1 credit expected expression error

So, I have gotten rid of all the errors and got the code to the point to prompt the user for the credit card number and output an answer the only problem is the program falls thru to invalid every ...
0
votes
1answer
1k views

How To Use a For Loop To Store Values Into Multiple Variables?

I'm working on the Credit problem set. Along the way, I've encountered a scenario where I want to use a for loop to store multiple values. If I type printf("%d", cc_number[p]); in that for loop, it ...
0
votes
1answer
38 views

Help in PSET1: Credit. Check50 not showing up

I finished (what I think) is a correct version of credit and when I submit, I only see marks for style and no check50 on the submit50 page. Also, when I do check50 in the terminal window, I get a "...
0
votes
1answer
126 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 ...
1
vote
2answers
145 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 ...