Questions tagged [pset1]

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

Filter by
Sorted by
Tagged with
5
votes
1answer
1k views

How long to wait for being graded

How much time does it take to get our psets checked? It's been more than two weeks since I submitted my pset1, yet it hasn't been graded. (I am doing CS50x)
1
vote
5answers
8k views

What's wrong with my code for mario?

I've been stuck on pset1 for five months now. I like to do things chronologically and mario has been giving me headaches. Every time I think I have the problem solved, I'm told it's wrong or a lot is ...
0
votes
1answer
255 views

pset1 - “greedy” failing at one value

So, I just finished typing my "greedy" code for the fifth time and thought that this time it actually works, but when I run the check it fails at only one value 4.2. I'm going to post my code and hope ...
26
votes
1answer
7k views

Greedy.c works for all numbers except 4.2

When testing greedy.c, all numbers appeared to work except 4.2 (annoying since 4.2 is in the check50 test). I get 22 coins instead of 18. I printed my variables at each stage of the problem and ...
3
votes
1answer
144 views

My output for greedy.c is correct when I check it manually but not when I check it using check50

It says that ' input of 4.2 yields output of 18 \ expected output, but not "18" '. What is the difference between 18 and "18" ?! Here is my code: #include <stdio.h> #include <cs50.h> ...
0
votes
1answer
527 views

greedy.c program compiler errors

I am a novice regarding compilers. Can somebody explain to me what the following printed errors mean? Since I was not sure whether I will be violating the Honor Code, I have not included my greedy.c ...
1
vote
1answer
2k views

Why does an input of 4.2 yield an output of 22 not 18?

I did all good in check50 .. except this one thing in greedy :( input of 4.2 yields output of 18 \ expected output, but not "22\n" This is my code
0
votes
1answer
315 views

pset1 Greedy can't compute pennies

I'm encountering some problem with my code with regards to pset1 Greedy! For some odd reason my code can't seem to compute pennies? So whenever i put in any values that has a 0.01 it won't calculate ...
0
votes
2answers
1k views

no such file or directory

I am trying to begin pset 1. I followed the instructions in the pset. After saving the file hello.txt, i execute the commands to open the file in the terminal by typing cd dropbox/pset1. I get the ...
0
votes
2answers
692 views

No rule to make target hello

I typed the program of problem set 1 and get the error message No Rule to Make Target hello. I run ls and I see hello.c in my dropbox pset folder. See screen shot.
0
votes
3answers
685 views

Mario Pyramid - Check50 - Unexpected end of input

Does anyone know what this means? I'm getting the correct output from my program and this is the only message I get from check50.
2
votes
1answer
9k views

Stuck on pyramid for mario.c

I have the first part of mario.c done. The computer asks the user for input and then continues to ask if the user does not input an acceptable number. However I am unsure of how to print the #'s and ...
2
votes
1answer
30k views

C syntax errors like “expected expression”

I completed an introduction to programming using Python and I am more used to Python then C, so I might mix the two up. C is giving me all kinds of errors. I tried changing things but noting seems to ...
0
votes
1answer
1k views

make: *** No rule to make target `hello'. Stop

Im unable to run make hello - I have read through the other troubleshoot but unable to find out what iam missing. Please can someone help me if I have entered something incorrectly. Error make: *** ...
3
votes
3answers
3k views

Stuck on PSet1: I have the correct output, but Check50 says it's wrong

I'm stuck on the Mario part of PSet1. I've managed to write up my program and the output is always correct (or at least seems to be to me). I know it's definitely the loops that are making things ...
2
votes
3answers
582 views

Getting error in pset1 mario more

In pset1 mario more problem i'm getting these errors. I don't understand the errors and how to correct this. :( handles a height of 2 correctly \ expected output, but not " # # \n## ##\n" :( ...
2
votes
1answer
214 views

How do I fix the precision error for convering float to int?

I'm taking the input via float f = GetFloat(); I enter 4.2 I multiply it by 100 and print the integer and I get 419. This is my output O hai! How much change is owed? 4.2 n=419 22 How do I ...
2
votes
3answers
810 views

Why don't I get the correct result when dividing numbers for greedy?

I was trying to use the remainder operator (i.e.,'%') to get the remainder, but I ran into an error: n % 25 is not evaluated to 23 when the input is 9.73. Am I doing something wrong here? Or is it ...
2
votes
1answer
274 views

check50 rejects greedy even if the correct answer is displayed

When I run check50 on pset1 it does not validate my solution, even if it says that the expected output is the same as the correct output. Does anyone know what the problem is?
1
vote
3answers
579 views

How to validate user input for greedy.c

How can I ensure that my program checks that a user enters a valid floating point value? I tried GetFloat but that only seems to return retry in the event that a user enters a non numeric value. If a ...
0
votes
1answer
37 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.
0
votes
1answer
274 views

What is wrong with this code for greedy (pset1)?

I have written the following code as a part of pset1 for greedy. I always seem to get a number less than the actual number of coins.Please help me out. #include <stdio.h> #include <cs50.h>...
0
votes
2answers
2k views

How to build the pyramid in pset 1?

I'm stuck on the mario problem in pset1! How should I start going about printing the half pyramid? I already figured the user input part...
0
votes
1answer
193 views

Does greedy's Output Have to Match The One Required per the Pset Specification Page?

I'm trying to check my greedy program with check50. I'm wondering whether my output must match the one required per the pset specification page. Here's check50's output jharvard@appliance (~/Dropbox/...
0
votes
3answers
157 views

Greedy hangs after prompting for user input

I'm a bit stumped at what I'm missing in my Greedy solution. The program keeps getting hung up right after the prompt for user input. Check50 doesn't give me much information to work from. What is ...
0
votes
1answer
420 views

Pset1 Hacker Mario has correct output but not passing check50

My Mario code for a double pyramid has the exact same output as the ~cs50 file. However, I can't get it to pass the check50 code. It seems as if the numbers 2-23 are not handled correctly, but again,...
3
votes
2answers
15k views

Problem with “expression result unused” error in for-loop

There is obviously something missing in my understanding of the for-loop. Part of my code looks like this: int height; do { printf("Height?: "); height = GetInt(); } while (height < 0 || ...
4
votes
2answers
65k views

Error: “make: *** No rule to make target `mario'. Stop.”

I keep receiving and the error message " *** no rule to make target 'mario' stop" when I try to make mario. Does anyone have any advice? I already typed in pwd and I'm in the Jharvard desktop. Any one?...
1
vote
1answer
126 views

How do I ensure that the user input in greedy is given to two decimal places?

I have a question about 'Greedy' in pset1. How do I ensure that the input I'm given by the user is in the correct format, namely to two decimal places like 0.00?
1
vote
1answer
107 views

I'm stressed, someone pls help

why cant this code work? it works on everything in check50 except for 4.2 pls tell me whites wrong #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float ...
1
vote
1answer
688 views

error: expected identifier or '(' with greedy.c

I've been working on greedy.c and received this error in terminal: greedy.c:23:1: error: expected identifier or '(' if cents > 25 ^ I thought it had something to do with the if...else statement I ...
1
vote
2answers
154 views

Problemset 1-setting up pset1 directorory in dropbox

Problemset 1-setting up pset1 directorory in dropbox When I downloaded Appliance 50-19 version and double clicked on the icon Home nothing happens. Hence I am not able to set up the directory pset1 ...
0
votes
1answer
97 views

Why Am I Getting These Symbols Printed Out?

I'm working on mario trying to print hashes and spaces, but rather I get these symbols printed out instead . Why am I getting these symbols? I'm using statements like these within my program to ...
0
votes
2answers
925 views

Compiler errors while using Clang [duplicate]

I have been using Clang Compiler and check50 to write the programs in pset1 i.e hello.c and greedy.c I have found that check50 appears to say that hello.c and greedy.c compile ,even though the Clang ...
0
votes
1answer
259 views

Final line format for greedy OK but check50 says: expected output, but not “0\n”

As per the specifications for greedy, my final line of code just prints an integer followed by \n. printf("%d \n", answer) but I get the same output as check50 rejects greedy even if the correct ...
0
votes
2answers
592 views

pset1 cash.c check50 outputs 1 error?

I am receiving this output from check50 on pset1 cash.c :) cash exists :) cash compiles :) input of 0.41 yields output of 4 :) input of 0.01 yields output of 1 :) input of 0.15 yields output of 2 :) ...
0
votes
2answers
644 views

Why Does greedy Fail Passing check50 Tests? [duplicate]

I completed the code and ran the program. I get the desired results, but when I run check I receive the following red lines: :( input of 0.41 yields output of 4 \ expected output, but not "Number ...
0
votes
1answer
137 views

Compilation Errors When Compiling greedy

For some reason, even though I have declared the float variable change in my greedy.c program, the Clang compiler gives an error message saying that I have not declared it. Even with 3 compiler ...
0
votes
2answers
512 views

“Killed by server” at the check50 test: rejects negative input like -.1

When I upload my program to check50, everything is green except I get this one error: :( rejects a negative input like -.1 \ killed by server What do I need to do to fix this?
0
votes
1answer
72 views

pset1 greedy check50 comparsion comes up with sad faces not sure why

So I'm unsure of why I'm getting the red sad faces :< It seems that my code is giving the same/correct answer.
0
votes
1answer
2k views

How to fix the “expression result unused” compilation error?

When I try to run this code through the compiler, I get the error: expression result unused referring to the line cents - 25; How do I fix this error? How exactly do I "use" the expression ...
0
votes
2answers
1k views

Tips on spaces and hashes Mario

So I've been on Mario for about a week now and I have the user input part and the rows right, and I just need someone to give me tips or how to get started on the spaces and hashes, and btw I really ...
0
votes
2answers
683 views

bash: ./mario: Permission denied in Mario problem pset1

I think I wrote my code correctly. I used the same algorithm in Java and it gave me the perfect output. Can someone please tell me what's not working for this one and why it wont even comiple? mod: (...
0
votes
1answer
141 views

pset1 credit: segmentation error

My approach is to take the user input in as a string, while forcing numeric input between 14 and 16 characters long. I think my code should do that, but I get a segmentation fault for numeric inputs ...
0
votes
3answers
3k views

How can I add alternate digits in credit.c?

I am currently trying to solve the hacker version of pset 1 (credit.c). I have successfully completed the rest of the psets (hacker and standard versions). I need to sum up the even (starting from 0) ...
0
votes
1answer
430 views

Why Do I Get Errors When Checking greedy with check50?

I recently finished my greedy program and checked it out using different values and it appears to work except for large numbers (more than 6 digits) because of the float problem. So, I checked it ...
0
votes
1answer
286 views

Credit Card Test Confusion

I am supposed to find if cc numbers are valid based on these rules: Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products' digits together. ...
0
votes
2answers
104 views

Greedy algorithm1

#include<cs50.h> #include<stdio.h> #include<math.h> int main() { float f=0; long int a=0,c=0; printf("Enter the float value:"); do { f = get_float(); }while(f <= 0); a = (...
0
votes
3answers
1k views

What is the difference between a library and a header file?

Specifically I'm confused about a line in an answer for another question (here: What does the linker do?) The #include pre-processor directive does not copy the code from libraries to your source ...
0
votes
1answer
184 views

Gradebook issue

So far i have submitted PSET0, PSET1, PSET2, PSET3. I have submitted both standard and hacker editions. I have following grades so far: PSET0....................1.0 PSET1 PSET2...............