Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pset1]

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

0
votes
1answer
26 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
11 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
27 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
16 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
46 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, ...
0
votes
1answer
46 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
27 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
0answers
16 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 :)) [duplicate]

This code is for the cash problem for problem set 1. I am trying to find my errors but can't find them. Is my syntax, or spacing wrong? My ideas? Anything would be helpful. Thank you in advance.
0
votes
0answers
8 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 :) [duplicate]

This code is for the cash problem for problem set 1. I am trying to find my errors but can't find them. Is my syntax, or spacing wrong? My ideas? Anything would be helpful. Thank you in advance.
0
votes
1answer
24 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
46 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
2answers
86 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
42 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
25 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
42 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
24 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
28 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
34 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
16 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
73 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
15 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
14 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
48 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
50 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
61 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
39 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
18 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
75 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
55 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
119 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
37 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
52 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
65 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
91 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
39 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
135 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
46 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
69 views

PSet1 cash, modulo problem

Why does this give 19 instead of 20 when change = 4.2? Thanks.
0
votes
1answer
105 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
28 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
46 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
145 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
28 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
32 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
80 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
15 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 < ...
0
votes
1answer
52 views

pset1 credit working only in certain cases

So, this is probably not a good solution of the problem, but I hoped it would at least work, after struggling with it for quite some time. It made me happy to see it worked for the first number I ...
0
votes
2answers
91 views

cs50 pset1 mario.c stuck

I am stuck on cs50 pset1 mario. Here is my code: #include <cs50.h> #include <stdio.h> int main(void) { int height; do { height = get_int(); } while ( height < 0 || height > 22 )...
0
votes
1answer
36 views

set1/cash (or greedy)/ Floating point imprecision and rounding requirement help

I think I have figured out a way to convert the users input from dollars to cents. I used the eprintf function and it works. However, when re-watching Zamyla's walk through she mentions towards the ...
0
votes
1answer
86 views

Pset1 Cash Understanding modulo operator and while loops

I'm trying to set up my solution to the Cash problem using modulo. The input seems to be working correctly so far. It only accepts positive numbers through the do..while loop. The problem I think I ...