Questions tagged [pset1]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
63 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
2answers
37 views

Pset1 How do I get my code to compile as it should?

I'm trying to get my code to compile properly and it just won't. I know the code works when using a printf and scanf but now that I've changed it to get_int and printf it is not working properly. I ...
0
votes
1answer
33 views

How to get my code to re-prompt when given a non numeric input?

So my code in C for the mario steps is correct except that it shows an output when foo is input rather than re-prompting for a valid integer. I did check50 and this was the only error. Where can I ...
0
votes
1answer
24 views

Mario steps: How to make it do the opposite of what has compiled?

How do I make my dots line do the opposite of what it is doing? It looks right if only I knew how to format the code to flip what has been done. How should I be thinking about fixing this? I've tried ...
0
votes
1answer
21 views

get_long seems to return the incorrect value

im on the credit problem trying to use get_long to get a card number, but when i print out the result of get_long, im getting a completely different number from the one i give it. the function looks ...
0
votes
1answer
90 views

pset1 less comfortable mario

Somebody please help me I have watched the walkthrough thrice, many different videos and searched for answers on reddit and stackexchange yet i've been stuck at this for hours now and cant get through....
0
votes
3answers
81 views

pset1 Mario more comfortable check50

I know this question has been asked several times but I haven't found an answer that worked for the issue I have. The output for my pset1 Mario more comfortable seems to be correct (including no extra ...
0
votes
2answers
44 views

PSET 1 Cash two inputs don't get appropriate value

I'm stuck trying to understand what's wrong with my code... When I check it I get this error message: :( input of 1.6 yields output of 7 expected exit code 0, not 1 But getting 7 coins for 1.6$ ...
0
votes
1answer
72 views

Pset1 Cash - Incorrect number of coins

I've put together a solution to the problem set Cash using division. When I run the program, it returns incorrect number of coins for most of the cases, e.g. change 61 - 244 coins, change 0.80 - 14 ...
0
votes
1answer
50 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
1answer
39 views

credit.c problem on some input nubers

Here is my final output to credit.c checksum = (checksum / 1) % 10; if (checksum != 0) { printf("INVALID\n"); } //Validation for American Express if (count == 15) { } //First Validation for ...
0
votes
2answers
64 views

Pset1 Cash (in C) array increment error

Context; I'm trying to solve Cash by; Taking positive integer user input, saves as float "ch" for change. (this as an implementation detail) Create an array "coin_val" with coin value by descending ...
0
votes
1answer
57 views

PSET 1 - Mario More (and less) timed out while waiting for program to exit

I have written the code that makes the pyramid exactly how I am supposed to make it look. When I try it on my local computer, it works, but check50 doesn't agree. check50 displays "timed out while ...
0
votes
1answer
53 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
147 views

PSET 1 Less Comfortable Mario (Right Sided Pyramid) Got it right by luck, don't understand what I coded

So after fiddling with this for about 2 days, I managed to get a working code that gives me the result I wanted, but the last part was pure luck and frustration as I entered random variables to see ...
0
votes
1answer
62 views

problem set 1 _ cash

The problem is that it works for some values and not for others even though the float value is rounded. pls help { float change; do { change = get_float("change: "); } while (...
0
votes
1answer
51 views

pset1 Cash question

For some reason sometimes it gets the answers right and others it gets the answer wrong, I'm stuck so I don't know what to do next. #include <stdio.h> #include <cs50.h> #include <math....
0
votes
0answers
40 views

pset1 Cash, keeps answering 1

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; int coins = 0; do { change = get_float("Change owed: "); } ...
0
votes
1answer
29 views

Second pyramid in mario, how to put that onto the same line as first pyramid

What should I do to join the two pyramids onto the same line? Output is: Height: 8 # ## ### #### ##### ###### ####### ######## # ## ### #### ##### ###### ####### ####...
0
votes
1answer
97 views

CS50 pset 1 cash problem: keep getting 1 as answer

I'm trying to do the CS50 cash problem and the answer keeps getting number 1 no matter which change I input. It won't accept negative numbers as asked by the problem, but I don't know why it doesn't ...
0
votes
1answer
20 views

PSET 1 - Where I have to make my answer to Mario PSET?

I am starting to write my code for Mario but I am lost. Where do I have to write it in the MarioCS50 LAB, or I have to create a new Sandbox? Thanks!
0
votes
1answer
66 views

pset1 cash: greedy algorithm coin change round off

The output is not being rounded off: It doesn't count the cents value if you input a dollar in decimal. if it's $45.67, it only counts change for $45. Also, output comes back 0 if the input is ...
0
votes
1answer
13 views

How to stop terminal process in CS50 Sandbox? (I've tried Ctrl-C and Ctrl-\)

I'm doing problem set 1 on the CS50 Sandbox, and have ran into some infinitely running programs. When I do ctrl-c or ctrl-\ (I am on mac and have tried both cmd and ctrl), the process still continues ...
0
votes
1answer
30 views

Setting Up PSET 1 IDE Issues

On getting into the PSET 1 IDE i just seem to have a completely empty IDE. For example when i follow the instructions on the CS50 PSET1 Page i get the following: ~/ $ update50 bash: update50: command ...
0
votes
1answer
42 views

Pset1 Cash, not returning any answer?

I've been attempting the Cash problem. There are no errors when I enter "make cash". But when I enter "./cash", it asks "How much change in dollars is owed?", I answer "0.41", then nothing happens. ...
0
votes
1answer
63 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
1answer
33 views

Pset1 Cash problem: error when trying to add quarters, dimes, nickels and pennies

i would really appreciate it if someone can point out the problems in my code. Basically what i am trying to do is to calculate the number of quarters, dimes, nickels and pennies needed, and then add ...
0
votes
1answer
26 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
2answers
39 views

PS1, Cash Question. Error when printing results of roundI() function

I am trying to print out the results of the round() function. #include <stdio.h> #include <math.h> int main(void){ float change = 4.2; //want change for $4.2 printf("rounded %i",...
0
votes
1answer
59 views

I am not getting the correct output when i enter David's card number in credit

This is my code: #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { int x, y, z, p, q, r, d, e; int k = 0; int s = 0; long A; long n = ...
0
votes
1answer
61 views

I am not getting the correct output on pset1 cash… Can someone please look at my code?

#include <stdio.h> #include <cs50.h> int main(void) { float change; int coins = 0; do { change = get_float("Change owed: "); } while (change < 0); int c = change * 100; while (...
1
vote
1answer
166 views

credit - Why this AMEX and MASTERCARD numbers are considered invalid?

I have compiled my version of credit, anyway check50 throws 2 fails during its check. Lines with numbers where it fails are: :( identifies 369421438430814 as INVALID expected "INVALID\n", not ...
0
votes
1answer
70 views

Problem Set 1 (Credit) - More Comfortable - 'Else' Block Not Running

I attempted Problem Set 1's 'More Comfortable' Credit assignment today, which is essentially to implement Luhn's mod 10 algorithm for checking that a given debit/credit card number is valid. I've ...
0
votes
1answer
87 views

Cs50 Pset 1 Cash

I am getting the desired number of cents however when I am submitting I am getting the below error :(. I tried to do some research but still not able to find the fault. Please check. Thank you!. :( ...
0
votes
1answer
36 views

Pset 1- Cash: Can't figure out why code takes a negative value

Despite my while loop demanding a negative number, it returns zero rather than returning back to the get_float. I'm sure this is something super basic, I just can't seem to figure it out. #include &...
0
votes
2answers
61 views

Pset1 cash answer incorrect

//I don't understand why answer shows incorrect include <stdio.h> include <cs50.h> include <math.h> int main(void) { { double n; int c=0; do { n=get_double(&...
0
votes
1answer
36 views

PSET1 One input doesn't give the appropriate output

My current code checks out all the input values except for the integer value of 23. I'm not sure why, and the value is pretty close, 94, instead of 92. But what makes me truly confused is that other ...
0
votes
1answer
114 views

Stuck on CASH problem pset1

I need help on why this is happening: I'm currently doing the cash problem. I used get_float to get user's amount and then used round(amount_from_user * 100) to convert the float to int (i.e cent) as ...
0
votes
1answer
52 views

(pset1 cash) getting correct answer in terminal output, but check50 shows wrong output

After I submitted my cash pset1, it returned three test cases(input of 1.6,23 and 4.2) giving the wrong output(7,92,18), also detailed in check50. But when I try the three test cases with my code, my ...
0
votes
1answer
73 views

pset1 submission issues

Hi I submitted pset1 mario and only got 65%. I went back to try and fix any issues to get a higher percentage but i just keep getting a lower % each time. I've tried to used check50 to check the code ...
0
votes
1answer
239 views

Pset 1: Credit problem - Checksum?

I'm having trouble with the checksum in the #credit problem. I have no clue on how to operate specific digits within the credit card number (specifically, multiplying the digits in the odd positions ...
0
votes
1answer
46 views

How do you check if a number is integer as part of if statement?

As part of the Mario assignment following lecture 1, I need to determine is the number input is an integer. What function can I use to do that? I have tried scanf("%d", &number), where number is a ...
0
votes
1answer
61 views

Stuck on pset1 - error: expected identifier or '('

I really wanted to find or discover the solution for myself, but after many hours I give up. Here is the error message and code, thanks. mario.c:19:1: error: expected identifier or '(' #include &...
1
vote
1answer
83 views

PSet1: Mario - Less Comfortable (Too many periods)

I recently just tipped my toes into the water of CS50 last week, I'm completely new to this so I need a bit of constructive critisism. I was completed stumped at first, but I got somewhat close - not ...
0
votes
1answer
173 views

Stuck at pset 1 mario problem

I'm Stuck at the PSET 1 problem of CS50. for height 3, my output is coming as ..# ..## ..### Can any peers or experts, look into my code and help me out. [EDIT: code removed for Honor Code ...
0
votes
1answer
290 views

Pset 1 mario (less comfortable)

I've been working on this problem for days and I can't figure out how to print the right side of the pyramid. I"m able to print the left side, preceded by a space (denoted by "y) and one hash. I've ...
0
votes
1answer
82 views

PSET1 clang hello.c

Can anyone tell me why I'm getting this error when trying to compile hello.c in the Terminal Window? $ clang hello.c hello.c:7:1: error: expected identifier or '(' { ^ 1 error generated. $ Thanks!
0
votes
1answer
19 views

The test shows this failure: expected exit code 0, not 4

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { // prompts user for amount of change until user enters a valid number float dollars; do { ...
0
votes
1answer
56 views

Modulo math and while loops in cash.c

I'm not sure why my while loops do not give me the correct answer: while (cents % 25 > 0) { count++; cents -= 25; } while (cents % 10 > 0) { count++; ...
0
votes
2answers
235 views

mario (less) getting 53% score

I submit pset1 Mario (less), and my code works correctly but in cs50.me showing that I have only 53% scores even though that my code work correctly. #include <cs50.h> #include <stdio.h> ...

1
2
3 4 5
22