Questions tagged [pset1]

The problem set for Week 1 introduces the C programming language.

Filter by
Sorted by
Tagged with
0
votes
1answer
68 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
3answers
112 views

Incorrect input of value yields incorect output in Cash task at PSet 1

My code #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float sum; int sumInt; // Check user input and convert it to cents do { //eprintf("about to ...
0
votes
2answers
32 views

Where my bug for problem set 1?

I'm seriously not sure what i'm doing wrong, i just copied and pasted the template from the problem.
-1
votes
1answer
53 views

pset1 ---------— mario less

I am not understanding as to what is expected when it says " rejects a height of -1 expected program to reject input, but it did not" what is "reject input"? please help
0
votes
1answer
76 views

Errors while check50 in Pset1 mario less, expecting suggestions

I am getting following errors with check50. Need help to understand which part of my code cant handle these situations. :( handles a height of 1 correctly expected "##\n", not "" :( ...
0
votes
1answer
233 views

Trying to make cash.c from pset 1 without mod

So I've made this program with modulus and it made sense to me, but when I ran it I got an error message saying I can't use mod on floats. Since then I've been trying to replace this: change = ...
3
votes
2answers
158 views

Which loop can be replaced for nested for loops for PSET 1 (Mario More Comfortable)?

According to the cs50 style guide for C, more than 3 variables for iteration is not a good practice. I have done Pset 1 (Mario more comfortable) with 5 for loops, so it has 5 iterations variables. Is ...
0
votes
1answer
124 views

about pset1 credit

I'm working on pset1 credit. To identify the valid credit card number. First I ask users to input a long long, which I made it a int so that i can make sure it fit the first requirement(any number > 0)...
0
votes
1answer
61 views

What's wrong with my Credit code? works for some and doesn't for the others

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardNumber; char cardNumberStr[16]; char cardNumberArray[16]; int i, numberOfDigits; int sum = 0; ...
0
votes
1answer
89 views

CS50x Cash Question

I'm working on the "cash" problem from CS50x pset1, and I'm having trouble finding the problem with my code. Most of the answers are correct, but when I input "0.56", the return value is "5" which is ...
0
votes
2answers
513 views

No rule to make target `mario1'. Stop

any advice would be great. Thanks!
0
votes
2answers
4k views

How to print a long number in C?

Hello I am very new to C but have some experience with python and would like to know how to print the outputs for the credit.c so I know what I am dealing with. I have this code and when I get to the ...
1
vote
2answers
53 views

Cs50 pset1 mario syntax errors or wrong code

Okay so I've tried multiple ways to get my blocks to simply create columns and rows first before adding spaces (though I've tried). I've watched and rewatched the lecture multiple times but I can't ...
0
votes
1answer
249 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 ...
1
vote
2answers
209 views

I can´t get (pset1) greedy/cash.c pennies to work properly!

i´ve been trying to figure out what is wrong with my code for the pset1 cash or greedy program, i know about float imprecision but when i print the last value for "ch" it prints .01000, thus meaning ...
0
votes
1answer
439 views

Receiving 'error: expected expression' for code inside if statement (pset1)

Originally, my if statements looked like these (please note that I didn't really write them one after the other like this): if (counterCardLength == 15 && FindFirstTwoDigits == 34 | 37) if (...
0
votes
1answer
1k views

pset1 | error: invalid operands to binary expression ('long long *' and 'int')

Here are snippets of my code: long long card = get_long_long(); long long *FindLength = *card; while (FindLength != 0) { FindLength = FindLength / 10; counterCardLength++; } And ...
0
votes
1answer
6k views

pset1 Error: indirection requires pointer operand

Here is a snippet of my code: long long card = get_long_long(); long long *FindLength = *card; long long *FindFirstTwoDigits = *card; And here are the errors: credit1.c:8:29: error: indirection ...
0
votes
2answers
150 views

:( mario.c compiles this looks like a compiling error

I have written the code for mario- less comfortable. But when I run check 50, it gives a error which states: :( mario.c compiles I am not being able to understand as to what is wrong.
0
votes
1answer
34 views

An error with my code?

So recently I made a code for the CASH project in CS50, but for some reason its giving me wrong values for the total amount of coins when I think the code is correct. I posted my code down below, ...
0
votes
1answer
36 views

CS50 Problem set 1 - my code is weird and maybe a bit hacky, need help!

I'm stuck on problem set 1 - less comfortable. This is what I have: #include <cs50.h> #include <stdio.h> int main(void) { float change; int numberofcoins = 0; do { ...
0
votes
1answer
52 views

Pset1: Error when trying to assign single digits of int variable to array using for loop

I'm currently working on Credit. I'm trying to find the first two digits of the card number using a for loop. I've created an array named firstdigits with two elements. Then I've created a for loop to ...
1
vote
1answer
145 views

PSet1 Cash returning implicitly declaring library function 'roundf' with type 'float (float)'

I am currently working on the pset1 greedy (cash) project. I am so close to finishing and I only have one more thing to complete before I can submit it as correct. I am working on rounding the initial ...
0
votes
2answers
133 views

Why isn't my block on pset1 turning into a staircase?

I am currently working on pset1 Mario, less comfortable. I am running my c to turn the hashtags into a staircase, but when I run the code, it is only a block. What is wrong with my code? Thank you all ...
1
vote
1answer
842 views

Problem with rounding for pset 1 cash

Desperately need help for pset 1 cash! My code failed 2 of the check50 tests: :( input of 23 yields output of 92 :( input of 4.2 yields output of 18 I believe it's a rounding problem, but I've been ...
1
vote
1answer
141 views

For mario less comfortable, I did it correct but i do not understand the logic behind it

my code for mario less comfortable is correct. But I got the answer by trying out different value multiple times. And after I finally got the correct answer, I do not understand the logic behind it. ...
0
votes
1answer
630 views

Problem with my credit code

Just finished working on credit and after testing it with the number in pset1 page it was working well and I have tested it against other numbers too the problem is when I ran check50 it said that ...
0
votes
1answer
343 views

Credit - Why Does it Fail Passing check50?

When sending my code to Check50, all the Credit Card checks go through ok but one: :( identifies 4062901840 as INVALID expected "INVALID\n", not "VISA\n" But doing the steps: 1) Multiply every ...
0
votes
1answer
60 views

credit.c code revieew

I spent a few hours on credit.c yesterday, and finally got it to compile and pass check50 (yay!). I wanted to know if anyone could look over my code for optimization and tell me if there were things I ...
0
votes
1answer
53 views

my code for pset1/mario/more not through by check50, can any one plz check and advice. thank you

#include <cs50.h> #include <stdio.h> int main(void) { int n; do { n = get_int("Height: "); } while(n <= 0 || n > 1); // Print out first row for(...
0
votes
1answer
626 views

Stumped on pset1 cash.c, please help me learn

I'm trying to create a solution for pset1 cash.c, the code below is not meant to be the final implantation, just a cursor to figure out the problem. When I run this code it works for values .01 to .05 ...
0
votes
1answer
73 views

Incorrect mastercard number in pset1 cs50 2018 [duplicate]

according to Luhn's algorithm, 5105105105105100 is invalid as the total comes out to be 25, but the check50 cs50 says its valid. and in places, they starting to double the digits from the first digit ...
0
votes
1answer
696 views

PSET1: Can't check hello.c

Doing on https://ide.cs50.io typing check50 cs50/2018/x/hello hello.c in ~/workspace/pset1/hello/ $ And got Uploading.. Unexpected token <
0
votes
1answer
210 views

pset 1 - mario (less) no output

I've typed make less in the terminal but nothing happens. Here's my code: #include <stdio.h> #include <cs50.h> int main(void) { // Ask user for height int height; do { ...
-1
votes
1answer
78 views

Im having trouble compiling hello.c.. What am I missing?

Here is the cs50 hello.c file as is. Why wont it compile? #include <cs50.h> #include <stdio.h> int main(void) { printf("hello, world\n"); }
0
votes
1answer
222 views

PSET 1: Mario help (Drawing pyramid)

Stuck on Pset 1 - drawing the pyramid (prompting the user for a number between 0 and 23 working fine). When I try to execute this program, it goes crazy- is there something wrong with my for loops? ...
0
votes
1answer
66 views

i've tried for a week to compile this. cs50 mario.c please help

#include <stdio.h> #include <cs50.h> int main (void) { int n = get_int("Height: "); for (int i = 1; 1 < n; i++) printf("#\n"); }
1
vote
1answer
80 views

Incorrect mastercard number in pset1 [duplicate]

by lunh algoritm result of calculating 5105105105105100 will be 25 and it means that this card is invalid, but check50 output this: :( identifies 5105105105105100 as MASTERCARD expected "...
0
votes
2answers
2k views

i am unable to submit my work in pset1 of marioless. It shows me a comment in yellow which says invalid slug.What should I do?

~/workspace/ $ submit50 cs50/2018/x/marioless Connecting.... Invalid slug. Did you mean to submit something else? ~/workspace/ $ submit50 cs50/2018/x/marioless Connecting..... Invalid slug. Did you ...
0
votes
1answer
82 views

problem at the output of credit (pset1)

i have problem with Credit (pset1), my problem is not about the algorithm but about something wired , the output of subtract and multiplication is not right at all first of all i get a valid input ...
1
vote
1answer
207 views

Problem Set 1: Greedy and While Loops

My program for pset1 (greedy) compiles fine and runs. However, it just prompts the user for the amount of change. After that, a result to show the number of coins never gets printed out, and the ...
0
votes
2answers
56 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, ...
1
vote
1answer
1k views

*** No rule to make target `hello'. Stop

I keep getting the error "*** No rule to make target `hello'. Stop." when I try to make hello; I searched for this error and tried cd pset1 for example, but it it still shows the same error; any ...
0
votes
1answer
46 views

Declaring an identifier in pset1 mario

I think I managed to work out (through a bit of hacking and a bit of luck) mario pset1. In saying that I still don't understand why I wasn't required to declare variables at the top of the programme ...
0
votes
1answer
121 views

Can make mario pyramid but am now unable to insert loop or inequalities

This is what I have so far: #include <stdio.h> int main() { int i, space, rows, k=0; printf("Height: "); scanf("%d",&rows); for(i=1; i<=rows; ++i, k=0) { ...
0
votes
2answers
61 views

pset1 - Cannot print returned value

I ran compile this: char get_credit_card_status(long long credit_card_number, char Luhn_validity)//, char credit_card_status) { char credit_card_status = 0; if (((credit_card_number < ...
-2
votes
2answers
370 views

:( cash compiles expected exit code 0, not 1

I have tried everything to solve this. I have searched googled, use help50 and even debugger50. My program runs fine, the problem consist when I use check50. i get " :( cash compiles expected exit ...
0
votes
1answer
90 views

Why does my code not print every other digit in a long long, and add them together?

Why won't this code print every other digit in a long long number (in this case, it's suppposed to be a credit card number), and add these numbers up? You'll notice I commented out several lines of ...
0
votes
3answers
245 views

Check errors pset1 - cash

After running check50 on my code for 'cash' in pset1 I'm getting the following errors: :( input of 1.6 yields output of 7 did not find "7\n" :( input of 23 yields output of 92 did not find "...
0
votes
1answer
81 views

cs50 - I can not clear check pset1 Mario less cause “…required files…”. I'm in the right directory.

The check50 is returning I have not created the file, which I see has been a problem others experienced, but all the solutions offered are to get into the correct directory. I am in the correct ...

1
3 4
5
6 7
22