Questions tagged [pset1]

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

186 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
84 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
758 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
0answers
97 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
68 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) ...
0
votes
1answer
57 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
268 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
54 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
128 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
1answer
205 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
86 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
1answer
70 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
45 views

Problems w/compiling pset1

Could anyone help me figure out why I can not compile, but get the following error: ~/workspace/pset1/mario/less/ $ make mario clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 ...
0
votes
1answer
69 views

Pset1 valid visa number as invalid

I built the first part to check whether a number is a valid AMEX number and used the same logic to check for Visa number but the codes don't seem to work as I tried with several valid visa numbers and ...
0
votes
3answers
125 views

Incorrect input of value yields incorect output in Cash task at PSet 1

My code #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float sum; int sumInt; // Check user input and convert it to cents do { //eprintf("about to ...
0
votes
1answer
265 views

pset1 credit assignment

I assume anyone looking at this question knows the assignment but to recap I need to write a program that will identify different CC#s—AMEX, MC, VISA, or Invalid. Since all these CCs range from 13-16 ...
0
votes
1answer
36 views

An error with my code?

So recently I made a code for the CASH project in CS50, but for some reason its giving me wrong values for the total amount of coins when I think the code is correct. I posted my code down below, ...
0
votes
2answers
140 views

Why isn't my block on pset1 turning into a staircase?

I am currently working on pset1 Mario, less comfortable. I am running my c to turn the hashtags into a staircase, but when I run the code, it is only a block. What is wrong with my code? Thank you all ...
0
votes
1answer
62 views

credit.c code revieew

I spent a few hours on credit.c yesterday, and finally got it to compile and pass check50 (yay!). I wanted to know if anyone could look over my code for optimization and tell me if there were things I ...
0
votes
2answers
58 views

Why does this code sometimes give me a different sum when i run it for the same cc number?

I'm working on the credit problem in pset1, and this is only part of what should be done. All I'm trying to do here is to multiply every other number (from the cc number entered by the user) by two, ...
0
votes
1answer
97 views

Why does my code not print every other digit in a long long, and add them together?

Why won't this code print every other digit in a long long number (in this case, it's suppposed to be a credit card number), and add these numbers up? You'll notice I commented out several lines of ...
0
votes
1answer
244 views

RE: Credit in PSET1

I have come up with, what seems to me, to be a logical walkthrough of the CREDIT problem (after banging my head against a wall for too long) - but the code does not make sense to the compiler. And I ...
0
votes
1answer
53 views

pset1: Printing too many hashes

for the past few weeks I've been struggeling with making the half-piramid in pset1. I managed to come up with this code that prints the height of the piramid according to the user input, but after ...
0
votes
0answers
66 views

Can't understand why i can't pass check50 for mario less

I'm totally confused, I tried every solution I could find, but still, I can't pass the check50. I keep getting the expected "##\n", not "#\n" error. i really need your help. here's my code: [removed ...
0
votes
1answer
31 views

When I enter input that is integer more than 23, the program stops. I think it is supposed continue prompting in this case. What's wrong?

#include <stdio.h> #include <cs50.h> int main(void) { int n; do { n = get_int("Height: "); } while (n<=0 || n>23); }
0
votes
1answer
148 views

cash.c I dunno which part is incorrect

I havent finished the whole, just the dollar part. But the formulation cannot be run correctly Can anyone tell me which part is incorrect?
0
votes
1answer
418 views

Pset1 cash. Please help me understand my script. Only works for 35 cents

I am working on pset1 cash. I'm taking it step by step trying to work out the issues so I know the logic isn't complete but I would really like someone's input explaining why my script only works ...
0
votes
1answer
38 views

Scores page shows “No Submissions” and no grade for pset1 even though already submitted

Yet the submissions page shows all the pset1 problems that I've submitted. Is this normal?
0
votes
1answer
115 views

Problem with my credit.c code

My credit.c code keeps inserting huge numbers in my array for seemingly no apparent reason. For example the user enters 45231 for the credit card number, the beginning of the array is fine and ...
0
votes
1answer
50 views

CS50 pset 1 water negative integers

Below is my code for the pset 1, im not sure why but whenever i put negatives for the "Minutes" i get a negative "Bottles" rather than an error. Help would be appreciated. #include <cs50.h> #...
0
votes
1answer
248 views

I finished pset1 mario.less but I don't understand my code

So I managed to finish pset1 mario.less but I'm really struggling to understand the logic behind my own code, the confusion comes into play once I get to the part where we begin building the half ...
0
votes
1answer
109 views

problem set1 pennies

I have another problem of imprecision with float numbers. #include <stdio.h> #include <math.h> #include <cs50.h> int main(void) { float z = 32212254690; float y = z / ...
0
votes
1answer
63 views

Error “ ~/workspace/strings/ $ make string make: *** No rule to make target `string'. Stop.”

I am following David in week one with the c coding. every time I run my code I get the following error ~/workspace/strings/ $ make string make: *** No rule to make target `string'. Stop. How do I ...
0
votes
1answer
2k views

Mario Less Comfortable, do-while loop problem

Hi everyone I made sure to do my research and go through the already posted questions. I am certain my while condition is wrong after research but don't understand the correction. my program runs but ...
0
votes
0answers
28 views

My greedy.c passed all tests except the 4.2 input

I went wrong somewhere with my code. For $4.20 yield it outputs 22 instead of 18. .41, .15; 1.6. 23 all yield correct results. int main(void) { float cents = -1; while( cents < 0 ) { ...
0
votes
1answer
55 views

Pset 1 expected expression

I've run into a problem on credit. Whenever I run this #include <stdio.h> #include <cs50.h> int main(void) { int credit; //Ask user for input of cc number printf("What is ...
0
votes
1answer
153 views

Greedy. Help? I have no idea what to do

If anyone could give me any pointers on what is wrong with my code, it would be greatly appreciated! Also, any tips on how to be a better coder? Should I read more books / articles? Honestly, I am ...
0
votes
1answer
68 views

pset1 confused with mario.c

I just started taking cs50. Just finished water.c and have to start mario.c but I can't figure out how to even start mario.c as in apply what I've learned in the first lecture into this project. It ...
0
votes
1answer
581 views

pset 1 credit.c

I started with the credit card case but I am lost I wrote this till now I want some help to know what to do next of course not giving the whole thing because this is the purpose of the course... ...
0
votes
1answer
39 views

Valid output decreed as invalid by check50?

I am having trouble with check50 in pset1 more mario. Below as follows is my code, it works. Yet, for some reason it is invalid. I know it is wrong to post my entire code but I am stumped. #include &...
0
votes
1answer
405 views

pset1 Mario Help?

So I understand the bases of the project, what I'm suppose to do etc, but when I prompt the user I get a bug, it also loops forever when I enter a negative integer is that normal? The do and while ...
0
votes
1answer
114 views

Something wrong with my credit.c code

I tried writing code for cs50 pset1's problem: credit.c(more comfortable) after week2. My code is given below. The problem is that 'sumx' and 'sumy' are just 0 and hence 'sum' is always equal to 0. So ...
0
votes
1answer
75 views

pset1 water how to ignore negative number

On the screenshot is the result after I typed a negative integer. How do I ignore the negative integers on bottles' result? Help pls. The positive & zero results are just fine, but the negatives ...
0
votes
1answer
56 views

I almost finished but my problem is with the side of the half-pyramid of mario

I finally reached the key for making this project but my problem is with the side of the pyramid i want it to be left sided instead. #include <cs50.h> #include <stdio.h> int main(void) ...
0
votes
2answers
250 views

My pset1 Water Code Works as per the Spec, but Doesn't Pass the Check50

so I am very new to this but I have written some code to complete the pset1 water task and it just won't pass through check50 2016.water water.c. I have put it below, I understand that it maybe all ...
0
votes
1answer
54 views

Can someone tell why a float variable also accepts an integer value when i use the cast option in my code for pset1?

The following is my code : float f; int counter = 0; float amount; do { printf("O Hai! How much money do I owe?\n "); amount = get_float(); } while(amount <= 0); /* rounds off the input ...
0
votes
2answers
80 views

Can someone please tell me the errors?

#include <cs50.h> #include <stdio.h> int main(void) { float dollar; int penny = 1; int nickel =5; int dime = 10; int quarter = 25; int cent, change; int a, ...
0
votes
1answer
222 views

Here's my code for “Greedy” . It works perfectly. Yet I got a score of 69. Could someone please tell me what's wrong with it?

#include<cs50.h> #include<stdio.h> int main () { **float f; do** { **printf("O hai! How much change is owed?\n"); f = get_float();** } **while(f<0); ...
0
votes
2answers
85 views

Problem Set 1: IDE

I'm very new to computer science and was attempting Problem Set 1 when I ran into some trouble and decided I wanted to start fresh. I ended up deleting all the files. Now I no longer have the /...
0
votes
1answer
35 views

Getting a chek50 error of not handling 0 correctly

In mario less pset1 when I run check50 the only error I get is the program does not handle 0 correctly. I have tried return 0; and repositioning things. I feel like I have to tell "C" to treat 0 and ...
0
votes
1answer
231 views

My Pset1 greedy code produces no errors and the wrong answer

I changed all the "remaining" to cents and its didn't work. I still can't see the logic why I made the made the change. I want to understand this. Here is my code: #include <cs50.h> include ...