Questions tagged [pset1]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
9 views

Query related to Mario program(more) in CS50 pset1

I can't figure out the problem in my code, it successfully creates a pyramid but doesn't reprompt when value other than 1-8 is entered, also it gives a space before printing the pyramid, causing ...
0
votes
1answer
8 views

CASH issue - help needed

I've been struggling with this for a month now so any help will be appreciated. The program just returns the value of input, so although there are no errors in compiling, it doesnt actually produce ...
0
votes
1answer
8 views

My program doesn't run when i close the condition's range. When i leave the range open it does't give the answer i want

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; int cents = 0, coin_number = 0, quart = 25, dime = 10, nickel = 5, penny = 1; //...
0
votes
1answer
12 views

Making code neater: a way to reduce repeated logical operators?

For CS50 pset1 Credit I'm using repeated logical-OR operators (||) to work out the validity and card brand of a credit card number. When I evaluate the style of my code using style50 it says to insert ...
0
votes
1answer
28 views

This is my code for cash

This is my code for cash idk what I did wrong cuz when I compile it, it gives me a decimal of the number I put in instead of a whole number representing how many coins. Idk what I did wrong. #include &...
0
votes
1answer
21 views

My code does what I want it to do, but I get errors with check50 (PSET1, MARIO, LESS)

When I run my code in the terminal it gives me the correct response. However, check50 indicates there is an issue with my spaces. I have spend 2 days looking at it but I dont know whats wrong. INPUT /...
0
votes
1answer
23 views

pset1 less greedy - keep on getting errors

I have added a first version of my code, however it is unable to compile and I just cannot figure out why. INPUT #include <cs50.h> #include <stdio.h> #include <math.h> int main(void)...
0
votes
1answer
20 views

cash less comfortable

I've been working on my cash problem but it keeps giving me error on the code especially the variables and I don't know why.
0
votes
2answers
39 views

mario less comfortable help

I wrote this code for the mario problem but idk if it's right. i'm having trouble running it. It keeps saying error: linker command failed with exit code. #include <cs50.h> #include <stdio.h&...
0
votes
2answers
20 views

rejects a height of 9, and then accepts a height of 2 expected “” #“\n”##“”, not “”

This is my solution for the cs50 pset1 (less). Passes ok all the test cases except for the "9 then 2" case. I tried it in the IDE myself and after passing 9 and the any other integer the ...
0
votes
1answer
38 views

Unable to compile pset1. Mario (Less comfortable)

I am unable to compile my file and get many errors. INPUT #include <cs50.h> #include <stdio.h> int main(void) //Prompt for the height of the pyramid int height; height = get_int (...
0
votes
1answer
23 views

My 'pset1 Mario more comfortable' is returning check50 errors whilst seemingly correct

I saw this question has been asked in multiple ways before but I believe I've checked answers and am still stumped as to the issue I have. The output for my pset1 Mario more comfortable appears to be ...
0
votes
1answer
19 views

PSET1 Cash, .41*100=0?

When I take the user input in dollars (as a float) and multiply it by 100 -- even when I then save that value as an intermediate float "cents" before changing it to an integer, for some ...
1
vote
2answers
23 views

ERROR PROBLEM SET 1- CS50 LIBRARY

I have included the cs50 library however, I am still getting an error. Input: #include <stdio.h> #include <cs50.h> int main(void) { printf("hello, %s\n"); } string name = ...
0
votes
1answer
47 views

PSET 1 Less comfortable Mario

I have been writing this code for a day but I still could not get the result I want, I don't even know how the is giving me a weird result. Here's my code: #include <cs50.h> #include <stdio....
0
votes
1answer
35 views

PSET1 Mario pyramid - Can someone explain me the logic of this line of code?

I was able to make the Mario's pyramid from Problem Set 1, (I know it should be right alligned, not left). This is the code, and it is working fine when I execute the program, but I don't seem to ...
0
votes
1answer
18 views

Errors on Mario pyramid

I thought had solved the Mario Pyramid problem until I got back all these errors :( handles a height of 1 correctly Cause expected ""# #"", not "" # # ..." :( handles a height of 2 ...
0
votes
1answer
12 views

Syntax Highlighting Error

I am working on my mario problem. I write my code in C, but it's not getting highlighted, meaning the program doesn't understand it. How can I get it to understand my code? for example #include is in ...
0
votes
1answer
39 views

Says that ./hello is a directory and error code when say clang -0 hello hello.c

I was following the directions from the website and was putting clang -0 hello hello.c I got an error code. I'm not sure if this means anything but when I put ls it says a.out* hello/ and hello.c. ...
0
votes
1answer
48 views

Greedy Algorithms PSET1. I wrote this code but at some cases it fails to give the correct output. Can someone please help me.?

#include <stdio.h> #include <math.h> int main(void) { float dollar; do //Loop to prompt user to type positive value { printf("...
0
votes
2answers
59 views

Problem Set 1 help, clang hello.c, and ls (list)

When I follow the directions from Problem Set 1 on the website, I get an error code when I type in clang hello.c and when i type in ls the list doesn't show up. Before I made the new file so I could ...
0
votes
2answers
50 views

PSET1 - Credit: Check50 says wrong what should be right

Someone with the same problem? I have a 16 digit number starting with a 4 and my code identifies it correct as VISA\n, but the check50 says it has to be INVALID\n. What could cause this strange ...
0
votes
2answers
46 views

Do - While loop

I am trying to do the Mario problem with C. The issue is that I want the user to select a number from 1 to 8. So my boolean expression is (n < 9 && n > 0). But I don't know why is not ...
0
votes
2answers
73 views

Incorrect output by check50

I worked very hard on Cash and finally produced compilable code and correct output. But when I ran check50 I got these results, shown here. Please help. My code is shown below, in case you need it. #...
0
votes
1answer
37 views

Cash.c:11:24: error: expected expression

#include <cs50.h> #include<math.h> int main(void) { int n = 0; do { n = (get_float("Change owed: ") * 100); } while (n < 0); int q = ((n / 25) %) ...
0
votes
1answer
27 views

Check50 issue pset1

This is the link that compares my output to expected output. https://submit.cs50.io/check50/cd17b70a3e377bfa9f3fabdff9d64aa91c23d9b3 Isn't it exactly the same. Still CS50 bot keeps rejecting it.
0
votes
1answer
33 views

"Error: Expected identifier or '(' in cash.c

#include <cs50.h> #include<math.h> do { int f = round((get_float("Change owed: ") * 100) } while (f < 0) q = ((f / 25)%) d = ((q / 10)%) n = ((d / 5)%) c = (n%) i ...
0
votes
0answers
15 views

I got a “linker command failed with exit code 1” error after compiling my source code

clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow mario.c -lcrypt -lcs50 -lm -o mario /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/...
0
votes
2answers
45 views

Pset1 Program does not stop printing dots dots/spaces for the pyramid and I don't understand why

After a certain number of iterations through the loops (lines 16 to 21), I expect the program to stop printing out dots since the "dotcount" should be equals to 0. However, an unnecessary dot is still ...
0
votes
0answers
60 views

I can't get the Luhn algorithm to run properly in my code

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardnumber = 0; //Prompt the user for the credit card number using get_long do { ...
0
votes
2answers
24 views

pset 1 Question about difference between Mario and Cash (get_float get_n)

As I was trying to structure the user input section of both problems, I ran into some errors that I don't understand. For Mario, I separated the user input of the problem and int main(void) by placing ...
0
votes
2answers
42 views

When printing mario problem the second triangle appears below the first one

#include <stdio.h> #include <cs50.h> int main(void) { //This do while loop checks if user entered number 1-8 int x; do { x = get_int("Height: "); } while ...
0
votes
1answer
51 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
35 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
32 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
19 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
0answers
77 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
72 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
40 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
61 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
48 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
36 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
61 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
49 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
51 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
141 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
55 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
49 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: "); } ...

1
2 3 4 5
21