Questions tagged [cash]

Cash problem in pset1

Filter by
Sorted by
Tagged with
1 vote
1 answer
12 views

pset1 cash compiles but gives unexpected outputs

I'm having trouble figuring out why I'm getting the outputs that I am. I tried to write a function that I can re-use for each denomination of coin, not sure if the problem is there or somewhere else. ...
if_indeed's user avatar
0 votes
1 answer
21 views

Week1 Cash problem scoping issue? Cents not updating

I have been trying to solve the cash problem but i think i'm running into problems with scoping between prototype, main and function updating the cents variable. I have tried a variety of variations ...
Berry6400's user avatar
0 votes
1 answer
19 views

Can someone help me understand why we multiply the quarters by 25

// Subtract the value of those quarters from cents cents = cents - (quarters * 25);
Victoria's user avatar
0 votes
1 answer
19 views

How to get value of variable after a loop

Here is my code to count the sum of 5 and 1 coin of a certain money to be the less. But I have to assign variable c to variable v because if not do so, the program will stop if the money is less than ...
binhsuy's user avatar
0 votes
2 answers
108 views

CS50 Week 1 Cash Problem question

EDIT - I changed a few things, and now I'm getting the error message below for line 49. Still needing some assistance to understand! I pasted the entire code below. I'm working on CS50 Problem Set 1, ...
AmyG's user avatar
  • 41
1 vote
1 answer
11 views

PSET 1 Cash - How to reject negative input?

I'm using a do..while loop in the get_cents function, which has worked for me in the previous problems. What makes this program incorrect? #include <cs50.h> #include <stdio.h> int ...
Elij's user avatar
  • 21
-1 votes
2 answers
27 views

PSET1: Receiving archive: cash.zip checkir error: cash exists but is not a directory unable to process cash/

Please see attached snippet below. I am having difficulty creating the 'cash' folder or directory. I have followed all the command prompts from 'cd' through 'wget https:' as shown in the cs50 ...
bdxltk35's user avatar
0 votes
0 answers
17 views

why, if coding in python, get_float accepts an int like 2 but not a float like 0.41?

In the pset6, exercise cash, get_float accepts an int like 2 but not a float like 0.41? This is a snippet from my python code: from cs50 import get_float owed = get_float("Change owed: ") ...
SaPe's user avatar
  • 1
0 votes
1 answer
48 views

problem set cash: why am I getting really high numbers in my return?

I'm very new to coding and I'm stuck on the cash problem set. It keeps returning a very high number and not returning cash. my code is below #include <cs50.h> #include <stdio.h> int ...
faeyb's user avatar
  • 7
0 votes
1 answer
34 views

Relational comparison unused in pset1 cash

I have a relational comparison unused and my code fails to compile. int get_cents(void) { // TODO int cents = 0; do { cents = get_int("Total cents owed: &...
deertom's user avatar
0 votes
1 answer
60 views

this program is supposed to be greedy algorithms that meant to count the number of coins to make the change owed = 0 , the output is always less by 1

#include <cs50.h> #include <stdio.h> int get_cents(void); int calculate_quarters(int cents); int calculate_dimes(int cents); int calculate_nickels(int cents); int calculate_pennies(int ...
ssan's user avatar
  • 3
0 votes
1 answer
17 views

How do I combine variables and words in a sentance?

printf("%i\n", quarters, "quarters,", "%i\n", dimes, "dimes,", "%i\n", nickels, "nickels", "%i\n", pennies, "pennies.");...
Harr's user avatar
  • 35
0 votes
1 answer
154 views

Getting: expected identifier or '(' error and I don't know why

int calculate_quarters(int cents); { // TODO int quarters; for(quarters = 0; cents >= quarters; quarters++) { cents = cents - 25; } return quarters; } The error happens ...
Harr's user avatar
  • 35
0 votes
0 answers
81 views

CS50 Cash 2022 - Functionality / Prompt Bug

*I am incredibly new to all of this, it's possibly operator error due to lack of familiarity with the software I actually understand the math and the set-up of the code, but I don't understand VS code ...
Olivia's user avatar
  • 1
0 votes
1 answer
2k views

declaration shadows a variable in the global scope [-Werror,-Wshadow]

#include <cs50.h> #include <stdio.h> int get_cents(void); int calculate_quarters(int cents); int calculate_dimes(int cents); int calculate_nickels(int cents); int calculate_pennies(int ...
Honoka Miki's user avatar
0 votes
1 answer
552 views

CS 50 Pset 1 cash: non-void function does not return a value

I have finish a program and it can run smoothly on other platform like replit... But one I run it on vs code it shows the following error and it also have something weird happen when I run check 50 ...
the-great-potato's user avatar
0 votes
1 answer
333 views

check50 issue on Problem Set 1: cash [duplicate]

I have finish my cash homework enter link description here But I face an issue that I can't check it even when I run the program successfully. My code is as below: #include <stdio.h> #...
the-great-potato's user avatar
0 votes
1 answer
287 views

Pset1 Cash 2022, doesnt print out # of coins

At first I solved and it works only with user check and not check50, so I tried to add the calculate functions and the get_cents but it wouldn’t print coins anymore. Please help!! When it worked: #...
Newbie86's user avatar
0 votes
1 answer
239 views

PSET 1 CASH stuck!

I am stuck with this problem. I'm wondering how to use the functions given to us at the top of the page (the template that was created after downloading the zip drive). There is a function about ...
Patsy Lin's user avatar
0 votes
1 answer
329 views

Problem with Pset1 cash 2022

I just try to do the Pset1 cash assignment and got a problem here(submit results). Got a message that expected prompt for input, found none for 41 cents, 160 cents, returns integer number of cents, ...
Claire's user avatar
  • 3
2 votes
1 answer
207 views

pset 1 cash – manual tests fine but still getting an error when I run check50

I've just finished cash and it seems to be working as expected when I run a manual test. When I run Check50 though I get the following message: :( calculate_nickels returns 5 when input is 28 expected ...
geman20's user avatar
  • 21
0 votes
1 answer
1k views

pset1 cash 2022

hello guys I got en error from check50 2022 which you can see it in my screenshot I check it 100 times but I can't resolve the problem can you please help me? #include <cs50.h> #include <...
Dayan Mehrani's user avatar
0 votes
1 answer
81 views

pset1 cash please help I'm stuck

can someone tell me why my code doesn't output properly? # include <stdio.h> # include <cs50.h> # include <math.h> int main(void) { int dollars; do { dollars = ...
Alae's user avatar
  • 1
0 votes
1 answer
25 views

function output?

I can't get this function to output the desired value of 0.07. #include <stdio.h> #include <cs50.h> #include <math.h> float i = 1.32; float quar_val = 0.25; int func(float val, ...
bob saget's user avatar
0 votes
1 answer
118 views

make: *** No rule to make target 'cash'. Stop

I have this problem. I'm trying to run this program but it keeps showing me this message and it confuses me since I have the file cash.c saved in the pset1 directory and cash (folder). I've looked for ...
Valentina Rivas's user avatar
0 votes
1 answer
101 views

Buy Finance Pset9 Cash not working

I am working on pset9 finance and I have been stuck for a while on it, especially this part: cash = db.execute("SELECT cash FROM users WHERE user_id = :userid", userid= ...
Connie's user avatar
  • 107
1 vote
1 answer
128 views

error: function definition is not allowed here( help!)

Not sure what the issue is, ive gotten this in all programs ive written with a function Would appreciate help Error message: cash.c:33:5: error: function definition is not allowed here #include <...
SeraphinaGG's user avatar
0 votes
1 answer
2k views

variable used in loop condition not modified in loop body

i'm having some trouble here, not even sure if my loop is correct but i'm also confused as to why I got this error about the why the cents variable can not be modified, if anyone can explain to me ...
user31964's user avatar
0 votes
2 answers
831 views

Imprecision during float subtraction in python

During pset6/cash, I tried to write the python code without multiplying change by 100 to get cents (as I had in c). I had assumed that this wouldn't lead to any precision issues, however when ...
Tim Swinn's user avatar
0 votes
1 answer
259 views

CS50 problem set 1 cash

#include <stdio.h> #include <math.h> #include <cs50.h> int main(void) { // Get float for cents // Take inputs of positive floats and repromt user for negative float ...
Nick's user avatar
  • 3
0 votes
1 answer
76 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 ...
Pedro Bogdanovich's user avatar
0 votes
1 answer
1k views

How to solve use of undeclared identifier error

In Cash of Problem Set 1, I'm quite sure that I've declared the variables used in the code, but I keep getting the error : error: use of undeclared identifier 'q' int coins = (q + d + n + p) ; I ...
Reba Philip's user avatar
0 votes
1 answer
61 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; ...
cs50studnt2021's user avatar
0 votes
1 answer
101 views

Cash Program not returning correct value for .41

I'm working on the Cash program in Week 2 and I think I have it all finished up the only problem is when I run check50 I get everything right except for .41 instead of returning 4 coins it gives an ...
Dre Johnson's user avatar
0 votes
1 answer
52 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 <...
Gabriel Berezovsky's user avatar
0 votes
1 answer
102 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 ...
Vabryn's user avatar
  • 1
0 votes
1 answer
67 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.
Saara Luthra's user avatar
0 votes
1 answer
48 views

Can you tell me my mistake

Please help, I don't know where the problem is.
Saara Luthra's user avatar
0 votes
1 answer
70 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 ...
Anastasia Toska's user avatar
0 votes
0 answers
31 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 (...
Anastasia Toska's user avatar
0 votes
1 answer
43 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 -...
Anastasia Toska's user avatar
0 votes
2 answers
213 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 ...
Anastasia Toska's user avatar
0 votes
2 answers
101 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 ...
Anastasia Toska's user avatar
0 votes
1 answer
601 views

Why do I get this "expected expression" error?

Like mentioned in the title, I get this "expected expression" error when I try to convert my amount from float into int type. Am I doing the conversion wrong ? Or is there something else I'm ...
Nomad's user avatar
  • 5
0 votes
2 answers
60 views

Cash 50 - Less Comfortable. Trying to nest so the algorithm will consider all money levels. Not working

coder newbie here. As far as I understand, this should work. This is the logic of my code... I get the float input from the user, and keep asking until I receive a positive number. I change this into ...
Catherine Mules's user avatar
1 vote
1 answer
29 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: "); } ...
Carl Singleton's user avatar
0 votes
1 answer
53 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 ...
DyRi's user avatar
  • 3
0 votes
1 answer
39 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 ...
Emily Rose's user avatar
0 votes
2 answers
241 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 (...
Angel's user avatar
  • 3
0 votes
1 answer
187 views

Having trouble with Cash but does not know what is wrong

I am having trouble with my code for pset1/cash. When I check the code, this is my output: :) cash.c exists :) cash.c compiles :( input of 0.41 yields output of 4' expected "4\n", not "...
stanloona's user avatar