Questions tagged [pset1-credit]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
26 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
15 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 ...
1
vote
1answer
65 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
20 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
1answer
41 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
2answers
42 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
30 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
33 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
0answers
12 views

segmentation fault when i compile my program

int main(void) { long long cardnumber = 0, calc; //string credit[1]; //string lengthkey[1]; string credit[1]; string lengthkey[1]; int countcardcharacters = 0; //user ...
0
votes
1answer
49 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
29 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 ...
0
votes
1answer
308 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
93 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
135 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 ...