Questions tagged [pset1-credit]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
16 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
19 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
34 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
32 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
27 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
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
22 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
76 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
118 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
55 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
45 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
79 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
35 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
122 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
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 ...