Questions tagged [pset1]

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

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

I have to enter any letter to get the result

I am currently doing the problem set 1 credit in cs50 program. I managed to write the code. It's compiles fine however once I enter the credit card number it stops, i must type any letter to get the ...
0
votes
1answer
23 views

Is there a way to replace the whitespace in the url whose part is some user input? i.e. User input contains whitespaces Pset1 (Wiki)

I'm doing a project of CS50's Intro to Web Programming with Javascript and Python(Pset1 : Wiki). While creating a new entry/page I'm asking the user for a title and content for the page. After which I'...
0
votes
1answer
15 views

pset1 credit; buffer overflow when converting to char array

My initial idea for the credit problem was to convert the long from get_long into a char array, in order to obtain something iterable to get each digit for Luhn's algo. I recognize that this could be ...
0
votes
1answer
39 views

Credit (Pset1) - Checksum problem

so I have a problem with the Credit exercise from pset1. I updated my code today after realizing that I didn't split up the digits of the product of the current digit in the card number and 2 and ...
0
votes
1answer
18 views

Pset1 “cash” question

this is my first question here so sorry if I do it wrong. My code compiles (it´s not finished yet), and it prompts, but when I run ./cash and type a number, It always gives me 0 coins, no matter what ...
0
votes
3answers
19 views

:( handles lack of argv[1] failed to execute program due to segmentation fault

if (argv[1] == NULL) { printf("Usage: ./caesar key\n"); return(1); } this is the solution before the program received the first statement validate null
0
votes
1answer
32 views

the code which is expected and my actual code are the same but check50 see it as incorrect LAB1

#include <cs50.h> #include <stdio.h> int main(void) { // TODO: prompt for the start size int n; do { n = get_int("start size: "); } ...
0
votes
1answer
64 views

My do-while loop does not work

do { number = get_long_long("What is your credit card number? "); } while((number < 1000000000000) || (number >= 10000000000000000)); This loop is not accepting inputs. I do not ...
0
votes
1answer
37 views

Problem set 1, Cash executuion issue

My code is as following: #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { //prompt for change float a = 0; int c = 0; ...
0
votes
1answer
33 views

make mario won't work but i'm in the correct directory

make mario won't work but I'm in the correct directory. I haven't even started writing the solution properly as I'm stumped on getting it to compile. Any suggestion? I tried restarting the IDE and ...
0
votes
1answer
35 views

How to submit Pest1 with SUBMIT50?

When I try to submit Pset1, in the terminal, it always does this: submit50 cs50/problems/2020/x/mario/less Connecting...... Authenticating..... GitHub username: A***********8144 GitHub password: ******...
0
votes
2answers
40 views

A problem with my code in PSET 1 Mario less comfortable

I think I have got everything right except when my program is run it prints an extra line without any hashes, can anybody point out or correct my arithmetic (or the code)? Here's the code: #include<...
-1
votes
1answer
32 views

CS50 IDE returns - bash: command not found

I get the following error while trying to execute a command. Example: ~/pset1/hello/ $ hello bash: hello: command not found 'make hello' worked fine: ~/pset1/hello/ $ make hello clang -ggdb3 -O0 -std=...
0
votes
2answers
30 views

pset1/credit outputs the right output but fails check

I'll share the printing part but not the calculation part, though happy to do that to it's just a bit lengthy. Nonetheless marked outputs are the right/expected output when run stand-alone but fails ...
0
votes
4answers
35 views

PSET1 So my code executes and prompt me for the money owed but that's it..nothing happens. Can someone point me in the right direction

I don't know what I'm doing wrong I get no errors. I feel like my code #include <cs50.h> #include <math.h> #include <stdio.h> int main(void) { float x; float a = 25; float b = 10; ...
0
votes
2answers
50 views

pset1 mario (less comfortable), expression error

I keep getting 'expression error' when I try to compile my code; any help would be appreciated. Code is as follows: #include <stdio.h> #include <cs50.h> int main(void) { // prompt ...
0
votes
2answers
44 views

Getting error on cs50 problem set 1 mario “handles a height of 1 correctly,timed out while waiting for program to exit”

Getting error on cs50 problem set 1 Mario "handles a height of 1 correctly, timed out while waiting for program to exit" Here's my code: #include <stdio.h> #include <cs50.h> int ...
0
votes
1answer
32 views

Problem probably related to floating numbers from CS50 pset1 cash

how you doing? I can't figure out where is the bug from my code :/ It's really strange and the results are not the same if you do the same test with "0.01", for instance... #include <...
0
votes
1answer
24 views

PSET1 Cash Outputting negative number?

I have a very bizarre problem I am experiencing. When I input any number the output by my program is as such: coins: 2 mQ + mD + mN + pN = -1055516176 When I run the program again it outputs nothing ...
0
votes
0answers
20 views

Help, doe not working - cash [duplicate]

Can someone please help me, as much as I think it should give the least amount of coins needed but it is not.
0
votes
1answer
35 views

Code not working - cash

Can someone please help me, as far as I think this code should give back the number of coins needed but it is not working.
0
votes
1answer
36 views

Can you tell me my mistake

Please help, I don't know where the problem is.
0
votes
1answer
36 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
47 views

Pset1 - Mario less printing 2 extra spaces

I have submitted mario.c and while it printed the pyramid, it is printing 2 extra spaces in front of each hash row. What am I missing here? #include <cs50.h> #include <stdio.h> int main(...
0
votes
1answer
34 views

pset1 credit solution. code not working but there is no bug

I wrote this code and I can "make credit". However, when I tested it with numbers, it doesn't work. Please see my code below. #include <cs50.h> #include <stdio.h> #include <...
0
votes
1answer
42 views

Can you tell me my mistake? ;)

Could anybody tell me what my mistakes are ? #include <stdio.h> #include <math.h> int main (void) { float dollar; do { dollar=get_float("Enter your ...
0
votes
0answers
25 views

Could anyone explain the error message?

#include <cs50.h> #include <stdio.h> #include <math.h> int main (void) { float dollar; do { dollar = get_float("Enter your change"); } while (...
0
votes
1answer
29 views

Could someone explain to me how curly braces work?

#include <cs50.h> int main (void) { int height; do { height = get_int ("Enter Height"); } while(...
0
votes
1answer
32 views

Im having a real hard time

I have a cash directory in which my source code cash.c and machine code cash are within. Why does this pop up? $ cd workspace $ cd cash.c $ make cash clang -fsanitize=signed-integer-overflow -...
0
votes
2answers
33 views

Hello everybody : ) Can you help me out?

$ clang cash.c /tmp/cash-94cd4e.o: In function main': cash.c:(.text+0x1c): undefined reference to get_float' cash.c:(.text+0x44): undefined reference to `round' clang: error: linker command failed ...
0
votes
2answers
43 views

pset1 cash THESE 2 ERRORS DROVE ME WILD help a newbie out, I will send you good vibes in return

error: expected identifier or '(' error: expected ';' after top level declarator int main (void) code #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) float ...
0
votes
1answer
60 views

pset1 credit: I am unable to identify what's wrong in the logic of my code?

Kindly tell me what mistake have I made in this program? pset1 Credit: (my code) https://pastebin.pl/view/5646dbf1
0
votes
3answers
48 views

When to Start the Next Week?

I finished the pset from Week 1 however I am still unable to finish the credit problem. Should I move on to Arrays and come back at a later time or wait until I am able to solve it?
0
votes
1answer
45 views

credit pset1 bruteforcing doesn't work

I was trying out credit and tried to write a code for all 15 digit cards so if a AMEX card exists it should work in theory. However even with valid cards I'm getting the input invalid. I have not ...
0
votes
1answer
21 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) ...
1
vote
1answer
23 views

I can't figure this out can anyone help PLEASE ( line 7 error) cash.c:7:1: error: expected identifier or '(' {

#include <stdio.h> #include <cs50.h> #include <math.h> int main (void); { float dollar; do; { dollar = get_float ("Where is my change: "); } ...
0
votes
0answers
18 views

Getting Incorrect Output but can't seem to find an error Pset1

I have written the following code for cash pset1 #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float dollars; do { dollars = get_float("Enter The ...
0
votes
2answers
68 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

CS50 PSET1 Hello, undefined reference to main

whenever i type clang hello.c it tells me that there is an undefined reference to main and i dont know how to solve this. please see the image to see my code and the error.
0
votes
1answer
45 views

CS50 Newbie needs help! Pset 1 cash problem. It compiles and runs but answers are wrong :(

Please check the code below. It runs fine but with a few "errors". when I input 0.41 as per the problem example, it gives me 16 coin count instead of 4. What is missing? Please help me ...
0
votes
1answer
25 views

Cash program only outputs input*4

I'm very new to coding and am really struggling with pset1- cash. I watched some tutorials and walkthrough videos, and with my limited knowledge, I cannot find any issue in the code I made. With the ...
0
votes
2answers
96 views

pset1 cash less, problem using for loops

I tried to use for loops to solve the cash (less) problem set, not sure if thats possible. Can this code be fixed or do I need to use while loops instead? the code compiles, but the output is either (...
0
votes
1answer
29 views

trouble summing the sides on credit

I have made it to the point it separates every digit into two sides so as to have two different sums, but then It gives me the wrong value of the sum. I'm pretty sure there is a bug in therms of it ...
1
vote
1answer
97 views

HELP, keep getting this error… error: invalid operands to binary expression ('float' and 'int')

Hi! keep getting this error in my code Could someone kindly help me figuring out whats wrong? Thank you :)
0
votes
0answers
20 views

My terminal showed ^L

I tried to clear the terminal by pressing command K (i have a mac) and the entire thing was cleared but it showed ^L. I can't fix it no matter what I do :< help would be appreciated thank you.
0
votes
1answer
136 views

Pset1 Mario - right-align the bricks - for function?

I've reached the point where I can create a pyramid but have an extra dot in the last row. Can't seem to remove it . Is there something i'm doing wrong in the nested 'for' function? #include <...
0
votes
1answer
23 views

“cash.c:7:1: error: expected identifier or '('” What do I do?

I've been trying to compile cash.c, but for a reason, it always says I have an error in line 7... could someone help me find the error...? I tried different things to try and make it work but it does'...
0
votes
1answer
19 views

Pset1 How to print variable to make sure input is correct?

In the Cash assignment, I am trying to print my variable cents to ensure it is properly stored. Why doesn't my code accomplish this? There is no output beyond the do while loop. Additionally, in this ...
0
votes
1answer
15 views

pset1 expression error

i keep getting this expression result unused in this line of the code else(cents>=1 && cents<5); . Any thoughts? do{ if(cents>=25){ tcoins++; cents=cents-25; } else if(cents&...
1
vote
3answers
72 views

PSET 1 Can't implement loop at the prompt

I'm still on my prompt part, couldn't get to the pyramid yet, my code compiles but I can't make the loop recursive, that is, after the first entry it goes back to the prompt $. Here is the code: #...

1
2 3 4 5
23