Questions tagged [pset1]

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

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

pset 1 Mario code starts with an empty row

I think I got most of it already but I have one issue that I don't see how to solve. If I make the height 8 (for example) it'll print 1 empty row first and then 7 rows with hashes, the last row will ...
0
votes
1answer
178 views

Hello.c pset1 problem, syntax error near unexpected token `(' and User input problem

Ive been doing pset 1 Hello and at the last part about User Input, Im at a loss for what to do. On the instructions, there are some hints where it says two commands. When I put down the two commands I ...
0
votes
1answer
82 views

Pset 1 .cash weird expected output

I finally managed to come up with something like this. I believe it works just fine but when the machine checks it, all the answers are wrong. E.g. when you are owed 0.41 you should get one from each ...
0
votes
1answer
675 views

How to return a value from a loop?

I have been trying to return value "a" to print it from while loop but can't find any ways so far. #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float ...
0
votes
1answer
111 views

CS50; PSet1; Don't know how to connect for loop with user's input + expected identifier or '(' error

I don't know how to properly connect user's input part and for-loop(which is incorrect) in this program. I was seeking for how to do this but didn't find anything useful. Here are my code: #include &...
0
votes
1answer
67 views

Why removing a printf function messes up with my code? CS50 pset1 cash greedy challenge

I finished the challenge and my first C code worked apparently well, returning each time the correct minimum number of coins needed for change. Then when I tried to "clean it up" a bit and remove a ...
0
votes
1answer
104 views

Can’t see my error on Mario for loop, rows won’t execute!

I’ve gotten stuck on the Less Comfortable Mario set: the height input portion works, but the loop does not execute. I really wanted to figure this out on my own, but I’ve been stuck for days! Please ...
0
votes
1answer
221 views

python pset1 cash problem

Trying to solve pset1 cash less comfortale with python. Whats my mistake as I cant figure it out. Lets say I add 5.16 as cash owed that is 20*0.25+1*0.1 +1*0.05 +1*0.01 , 23 coins total used. ...
0
votes
1answer
79 views

Pset1 cash.c Can't seem to wrap my head around it

So I'm just trying to slowly navigate my way through this problem by seeing if I can get the total amount to subtract 25 from the float. I keep getting an error message that says cash3.c:18:27: ...
0
votes
1answer
466 views

I keep getting error: use of undeclared identifier 'n' when trying to compile mario.c. I am new to coding, my code is shown below

#include <cs50.h> #include <stdio.h> int get_positive_int(string prompt); int main(void) { { int i=get_positive_int("Height:"); } for (int i = 1; i < n; i++) ...
0
votes
1answer
331 views

Struggling with Mario (less comfortable) loop conditions

Been struggling with this a few times now and have inserted some additional printf commands to try and understand what's going on with the variables used to control my loops (please see instructions, ...
1
vote
1answer
524 views

Doing mario.c less comfortable one step at a time

Like many others here I am completely new to coding. No experience whatsoever. I have been busy with the less comfortable Mario.c for a while now, trying to understand what is going on every step of ...
0
votes
0answers
92 views

Pset1 mario only executing do-while loop

So i've spent way too much time on this. Didnt expect it to be so difficult. I think i got the coding right but for some reason the program is only executing till the do-while loop and then it exits ...
0
votes
1answer
59 views

Need help with my code! It will not compile and everything seems like it is correct. Please help and give me some pointers. Thanks in advance :)

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float f = get_float("How much change is owed: "); } float f = f x 100; int c = 0; while (f >= 25) ...
1
vote
2answers
99 views

I don't know why check50 HATES ME?! mario.more

Here's my code for mario.more. [removed solution code] When i execute this code, it performs exactly how it should look according to Walkthrough: But when I run check50, the terminal goes like ...
0
votes
3answers
550 views

I am ABSOLUTELY STUCK! (mario less)

Ok, I have tried and have gotten a 60%. I need at least a 70% to pass. Please. Help. Me. Please. Tell. Me. What. Do. I. Do. I am done cash and now I'm stuck on this! Here is my code: #include <...
0
votes
1answer
82 views

It doesn't work?!!! (Mario less)

Ok so this is my code: #include <cs50.h> #include <stdio.h> int main(void) { int n; do { n = get_int("Height: "); } while (n <= 0 || n > 23); for (int i = 0; i <= n; i++) ...
0
votes
1answer
58 views

pset1 credit formula to extract digits keeps returning 0 (potential data type issue?)

Below is the block of code that i have issue with. I'm using this method to extract the digits: num[i] = (num % pow(10, i))/pow(10, i-1). The pow1 and pow2 variables print out correctly, but "digit" ...
0
votes
1answer
114 views

Need guidance on Mario (Less Comfortable) Problem Set 1 (Pyramid upside down)

I recently got to trying to solve problem set 1, where I am required to print a pyramid with a user inputted value between 1 and 8 (inclusive). After a while, I got this code: #include <cs50.h> ...
0
votes
1answer
75 views

I need help with cash - again

Ok so this is my improved code: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float c; int a, n=0; do { c = get_float("Change: "); } while (...
0
votes
1answer
88 views

I need help. (pset 1 - cash) I don't get this!

So this is the code I have now: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float c; int i; do { c = get_float("Change: "); } while (c <...
0
votes
1answer
51 views

I don't understand where I went wrong?

So this is the code I have right now for cash in problem set 1. I don't know whats wrong. #include <stdio.h> #include <cs50.h> #include <math.h> int maid (void) { float c; ...
0
votes
1answer
24 views

Transform function into a loop or similar

So my problem is in problem set 1 of week 1 of the CS50 Harvard course. The task was writing a program that calculates the smallest amount of coins possible when getting change. I've already written ...
0
votes
1answer
371 views

How to print out hashes in mario(less comfortable)? (2019)

Ok so this is my code I have right now: #include <cs50.h> #include <stdio.h> int get_positive_int(string prompt); int main(void) { int i = get_positive_int("Height: "); for (i = 0; i < ...
0
votes
1answer
43 views

The program not displaying the correct output for CREDIT Pset1

i have written the program for the credit but is not giving the expected output please let me Know if my code requires any change or if the logic is correct or wrong let me know. here is what i get ...
0
votes
1answer
20 views

Small difference in pennies.c answers

Good day, I am very new to coding and trying my best, but my answers are correct for this problem, but not after the decimal. For example, the answer for 28 days in month and 1 pennies must be ...
1
vote
2answers
123 views

error at while loop cs50 Pset1 credit

I am getting an error at while loop it says error: '&&' within '||' [-Werror,-Wlogical-op-parentheses] while((credit % 10 >= 0) && (i < 15) || (i < 16)) here is my ...
0
votes
1answer
101 views

pset1 - problem with credit ..help plz

I spent so many hours and still can't figure the problem, any guidance would be appreciated.. I checked against all the paypal test numbers and got same response as the staff's execution, though I got ...
0
votes
1answer
234 views

pset1 - Mario less comfortable - Styling problem

Could any one please tell me what's the "styling problem" in this code? I keep getting score of 4 out of 5 and I don't understand what I miss ? #include <cs50.h> #include <stdio.h> int ...
0
votes
1answer
52 views

pset1 mario uncomf - Hash's start in wrong place

I've ran into what appears to be a problem. I initially thought I finished this pset but when I was checking my work I noticed the #'s always started from the 8th character along the line? Even if I ...
0
votes
1answer
19 views

Adding a code block to perform operations on float

I am currently on PSET 1 Cash and have my program asking for the amount of change required, not accepting negative values and now I want to add a code block to start performing the operations on my ...
0
votes
1answer
112 views

Pset 1 Less comfortable - Number of Hashes

Sorry for the beginners's question. When I try to compile to following code for the Mario - Less Comfortable problem, I am printing the same number of hashes for each row and am unsure why. Code is ...
0
votes
2answers
78 views

Problem Set 1, Cash: maths issues

I have been trying to fix this code for the last day, and still can't work out where I am going wrong. Can anyone point me in the right direction please? Thanks in advance! int main(void) { // ...
0
votes
1answer
801 views

Pset 1 - Mario pyramid trouble with spaces/dots

So I was able to set up the prompt and the left aligned pyramid correctly, but really started struggling when trying to right-align it with dots in front of the hashes. For whatever reason, its ...
0
votes
2answers
84 views

pset1 always adding extra one space on each Hash row

#include <cs50.h> #include <stdio.h> int main() { int height; do { height = get_int("Enter the height between 1 & 8\n"); }while(height<1 || height>8); for(int i=0; i<...
1
vote
1answer
138 views

pset 1 cash get_positive_float not functioning as intended

I wanted to get the positive float using the get_positive_float function, which I declared later. However, it either accepts -0.99999 or rejects 0.999999. The code looks as follows: #include <...
0
votes
1answer
101 views

pset1 - credit - if-else statement issue

I have written a (clumsy) solution to the credit pset1. However, the solution only works for "Mastercard" credit card numbers (i.e. 5555555555554444). For "Visa" and "Amex" my code does return the ...
0
votes
1answer
546 views

incompatible pointer to integer conversion initializing 'int'

#include <stdio.h> #include <cs50.h> int main(void) { printf("Give me a number between 1 and 10"); int n= get_int; if (n>=0 && n<=3) { printf("You ...
0
votes
1answer
78 views

pset1 - credit fails check50 compilation with “expected exit code 0, not 1” but compiles locally

My solution for "credit" compiles just fine with make, but when using check50, I get :( credit.c compiles. expected exit code 0, not 1 My code is as follows: #include <stdio.h> #include &...
0
votes
1answer
512 views

pset 1 Cash Question: runtime error: signed integer overflow problem

I am very new to coding and I can't seem to understand what is causing the runtime error: signed integer overflow. My code runs and allows me to enter a change amount when prompted, but fails after ...
0
votes
1answer
107 views

PSET1 - Credit Checksum Problem

{ long long l; do { l = get_long_long("Number: "); } while (l < 0); float count = 0; long long m = l; while( m != 0) { m /= 10; count+...
0
votes
1answer
129 views

PSet1 cash, modulo problem

Why does this give 19 instead of 20 when change = 4.2? Thanks.
0
votes
3answers
6k views

Problem with pset 1, cash

I get the correct answer for some values, i get the wrong answer for others. I didn't convert my change to cents because I figured I could just keep all my cents, dimes, quarters in decimal values too....
0
votes
2answers
52 views

Not In Directory In Terminal Window pset1/mario/less

In the terminal window the current directory is always shown on the line where a command can be typed in. While working on pset1/mario/less somehow I have created the issue by which the current ...
0
votes
1answer
60 views

Why is my program not entering the while loop in greedy? Pset1

While I was trying to solve the greedy less comfortable problem in pset1, I ran into a slight problem on the last loop in my program. Here is my code: (the reason why I have some random print ...
0
votes
2answers
262 views

Need help in pset1: mario.c

I've been trying to do the less comfortable version of mario.c for a while, here is what I've been able to put together so far: #include <cs50.h> #include <stdio.h> int main(void) { // ...
0
votes
1answer
451 views

Mario error: expected ';' at end of declaration…all solutions i've found fail

i've been wasting hours going round in circles. Frustrating that first steps of learning are this hard.][4] i;ve removed the semi-colon and moved the curly hash together and separetely to no avail.
0
votes
2answers
61 views

Problem with credit.c concerning if loops with multiple initial conditions

I am working on the credit.c code. I am trying to make sure that the number of digits and the first digits of each credit card number value that is entered correspond with the brand that credit card ...
0
votes
1answer
201 views

PSET 1 Introduction to Python and Javascript linking database issue

I am having issues linking my flask program to Postgre SQL import os from flask import Flask, session from flask_session import Session from sqlalchemy import create_engine from sqlalchemy.orm ...
0
votes
1answer
17 views

Why does my program only work on int numbers, not on float ones?

#include <cs50.h> #include <stdio.h> int main(void) { float change, quarter, dime, nickel, penny; int coins; do { change = get_float("Change: "); } while (change < ...

1 2
3
4 5
22