Questions tagged [pset1]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
2 views

credit pset1 cs50 sum while loop

I was doing the credit problem with the visa test card in the page: 4003600000000014 It passed that test, however in other tests it doesn't pass. I think it's a matter of the sum that it can't compute ...
0
votes
1answer
116 views

Problem Set 1 (Credit) - More Comfortable - 'Else' Block Not Running

I attempted Problem Set 1's 'More Comfortable' Credit assignment today, which is essentially to implement Luhn's mod 10 algorithm for checking that a given debit/credit card number is valid. I've ...
0
votes
1answer
76 views

Need help (or idea) making the code looks cleaner. (PSET1/CREDIT)

My code passed pset1/credit but I still think the there must be a way to make my code looks cleaner and more impact. If you have any idea please criticize the code. Thank you in advance. #include <...
0
votes
4answers
701 views

mario.c; error message: expected identifier

I have been trying for more than a week to correct compiling error: mario.c:19:1: error: expected identifier or '(' The response I received did not help. #include <cs50.h> #include <stdio....
0
votes
2answers
23 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 ...
0
votes
1answer
42 views

How to get my code to re-prompt when given a non numeric input?

So my code in C for the mario steps is correct except that it shows an output when foo is input rather than re-prompting for a valid integer. I did check50 and this was the only error. Where can I ...
0
votes
1answer
67 views

Pset1 Creating and Changing Directory Does Nothing

For the first problem set, I attempted to create and change the directory with the following commands: $ mkdir ~/pset1 $ cd ~/pset1 $ mkdir ~/pset1/hello $ cd ~/pset1/hello Despite doing these ...
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
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
1answer
139 views

pset1 cash: greedy algorithm coin change round off

The output is not being rounded off: It doesn't count the cents value if you input a dollar in decimal. if it's $45.67, it only counts change for $45. Also, output comes back 0 if the input is ...
0
votes
2answers
50 views

why does this not allow coins =0.01 and greater?

{ float coins; do { printf ("please pick an positive number\n"); coins = GetFloat(); } while ( coins < 0.01 ); printf("%f", coins ); }
0
votes
1answer
60 views

HELP ME!! CS50 pset1 credit.c says INVALID but when I debug it says AMEX?

#include <stdio.h> #include <cs50.h> int main(void) { long long cc; //get user input for cc do { cc = get_long_long("Number: "); } while (cc <= 0); /...
0
votes
3answers
522 views

check50 is getting a different result from me on mario

I have tested every criterion of Mario, and they all are met, but check50 is getting a different output than me. Here is a transcript of what happened. elephant1123@ide50:~/workspace/pset1 $ ./mario ...
0
votes
1answer
37 views

function definition

#include <stdio.h> #include <cs50.h> int AnimalCategory(int); //function prototype int CurrencyCategory(int); //function prototype int ScienceCategory(int); // function prototype int ...
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
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
1answer
30 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 ...
0
votes
1answer
31 views
0
votes
2answers
92 views

Pset1 Cash (in C) array increment error

Context; I'm trying to solve Cash by; Taking positive integer user input, saves as float "ch" for change. (this as an implementation detail) Create an array "coin_val" with coin value by descending ...
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
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
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
42 views

PSET1 One input doesn't give the appropriate output

My current code checks out all the input values except for the integer value of 23. I'm not sure why, and the value is pretty close, 94, instead of 92. But what makes me truly confused is that other ...
0
votes
1answer
42 views

PSET1 Mario turning the stairs

I can't understand the logic of turning the stairs around. I ve spent hours looking it up and re watching the video... Can someone explain it to me using pseudocode?
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
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
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
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
56 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
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
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
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
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
0answers
18 views

PSET1 - credit ,not satisfying all test cases ,please help

These are the test cases which my code doesn't satisfy ,can someone please help me out as i have absolutely no idea why it is happening. Some tips or advice would be handy. Thank you in advance. :( ...
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
102 views

Incrementing values using variables

This is my code for incrementing either positively or negatively but somehow the code compiles but dosen't work. #include <cs50.h> #include <stdio.h> int main() { int Ini, Con, Incre;...
1
vote
1answer
16 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 <...
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
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
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
52 views

PSet1 Credit Invalid VISA that shows as Valid. My checksum must be wrong but dont know why

*/Here is the error I get: :( identifies 4111111111111113 as INVALID expected "INVALID\n", not "VISA\n" :( identifies 4222222222223 as INVALID expected "INVALID\n", not &...
0
votes
1answer
45 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
1answer
76 views

pset1 greedy – get as results ten digits numbers *SOLVED*

I implemented my greedy with modulo and it works for many numbers but not for 0.01 and 0.15 :( input of 0.01 yields output of 1 \ expected output, but not "2058567041\n" :( input of 0.15 yields ...
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
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
48 views

Pset1 I cannot print the correct amount of coins returned (greedy)

I'm trying to solve the less comfortable problem set of week1. I believe I'm somewhat on the correct road (at least i can get a return number). From how I implemented my code, it seems that when I ...
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
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
1answer
121 views

Please help!! Pset 1: creating a pyramid

I have been struggling with pset1: creating a pyramid for a long time. I am reading other people's codes to learn the logic but I still cannot understand what is going on. Would you please explain the ...
0
votes
1answer
67 views

Pset1 Cash less comfortable - not running for 0.41 and 0.01

-- hi im running into a problem with my code. It's executed pretty well with many inputs except for 0.41 and 0.01. It didn't print out any answer but just ran indefinitely... #include <stdio.h> #...

1
2 3 4 5
23