Questions tagged [pset1]

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

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

pset1 credit: I am unable to identify what's wrong in the logic of my code?

Kindly tell me what mistake have I made in this program? pset1 Credit: (my code) https://pastebin.pl/view/5646dbf1
0
votes
3answers
35 views

When to Start the Next Week?

I finished the pset from Week 1 however I am still unable to finish the credit problem. Should I move on to Arrays and come back at a later time or wait until I am able to solve it?
0
votes
0answers
24 views

credit pset1 bruteforcing doesn't work

I was trying out credit and tried to write a code for all 15 digit cards so if a AMEX card exists it should work in theory. However even with valid cards I'm getting the input invalid. I have not ...
0
votes
1answer
18 views

expected expression error in pset1 credit for loop

I am getting a error in the following line long checksum = (long) for (int i=1; i < 8; i=i+2) { if (checksum > 9) { (((long) 2*(credit_number % (long) ...
1
vote
1answer
15 views

I can't figure this out can anyone help PLEASE ( line 7 error) cash.c:7:1: error: expected identifier or '(' {

#include <stdio.h> #include <cs50.h> #include <math.h> int main (void); { float dollar; do; { dollar = get_float ("Where is my change: "); } ...
0
votes
0answers
15 views

Getting Incorrect Output but can't seem to find an error Pset1

I have written the following code for cash pset1 #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float dollars; do { dollars = get_float("Enter The ...
0
votes
2answers
37 views

Can anyone help me troubleshoot my code for the CS50 Credit problem? (**not trying to cheat, just need some help!)

This is the code I have written in c for the cs50 credit pset 1 problem. I am checking the length of numbers entered, and the first digits (AMEX 15 digits, starts with 34 or 37; MC 16 digits, starts ...
0
votes
1answer
13 views

CS50 PSET1 Hello, undefined reference to main

whenever i type clang hello.c it tells me that there is an undefined reference to main and i dont know how to solve this. please see the image to see my code and the error.
0
votes
1answer
37 views

CS50 Newbie needs help! Pset 1 cash problem. It compiles and runs but answers are wrong :(

Please check the code below. It runs fine but with a few "errors". when I input 0.41 as per the problem example, it gives me 16 coin count instead of 4. What is missing? Please help me ...
0
votes
1answer
23 views

Cash program only outputs input*4

I'm very new to coding and am really struggling with pset1- cash. I watched some tutorials and walkthrough videos, and with my limited knowledge, I cannot find any issue in the code I made. With the ...
0
votes
2answers
46 views

pset1 cash less, problem using for loops

I tried to use for loops to solve the cash (less) problem set, not sure if thats possible. Can this code be fixed or do I need to use while loops instead? the code compiles, but the output is either (...
0
votes
1answer
26 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 ...
1
vote
1answer
29 views

HELP, keep getting this error… error: invalid operands to binary expression ('float' and 'int')

Hi! keep getting this error in my code Could someone kindly help me figuring out whats wrong? Thank you :)
0
votes
0answers
17 views

My terminal showed ^L

I tried to clear the terminal by pressing command K (i have a mac) and the entire thing was cleared but it showed ^L. I can't fix it no matter what I do :< help would be appreciated thank you.
0
votes
1answer
77 views

Pset1 Mario - right-align the bricks - for function?

I've reached the point where I can create a pyramid but have an extra dot in the last row. Can't seem to remove it . Is there something i'm doing wrong in the nested 'for' function? #include <...
0
votes
1answer
21 views

“cash.c:7:1: error: expected identifier or '('” What do I do?

I've been trying to compile cash.c, but for a reason, it always says I have an error in line 7... could someone help me find the error...? I tried different things to try and make it work but it does'...
0
votes
1answer
17 views

Pset1 How to print variable to make sure input is correct?

In the Cash assignment, I am trying to print my variable cents to ensure it is properly stored. Why doesn't my code accomplish this? There is no output beyond the do while loop. Additionally, in this ...
0
votes
1answer
13 views

pset1 expression error

i keep getting this expression result unused in this line of the code else(cents>=1 && cents<5); . Any thoughts? do{ if(cents>=25){ tcoins++; cents=cents-25; } else if(cents&...
1
vote
3answers
57 views

PSET 1 Can't implement loop at the prompt

I'm still on my prompt part, couldn't get to the pyramid yet, my code compiles but I can't make the loop recursive, that is, after the first entry it goes back to the prompt $. Here is the code: #...
0
votes
1answer
37 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
31 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> #...
0
votes
1answer
77 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
48 views

Question about Pset1 - credit

I had work on the credit for 3 hours, and I had reach to most of the function - and I checked that the number received from: Luhn (a) last digit(c) and digit count (cc) are right by using ...
0
votes
1answer
36 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
82 views

Help with Problem Set 1 Mario (less)

I have no idea what I am doing wrong here. Everything works just as specified, but for some reason I am still getting error messages. Please do not look at this if you have not already solved the it ...
0
votes
1answer
15 views

Directory structures

I'm trying to create a new directory inside my pset1 directory. When I execute "~/ $ mkdir ~/pset1/mario" I get "bash: /home/ubuntu/: Is a directory". I think I need a better ...
0
votes
1answer
31 views

Cannot compile Mario (less comfortable) in PSET 1

I have finally made code that works and allows itself to be "made". However when I try to compile the code to submit it, it presents me with an error that says "undefined reference to '...
0
votes
2answers
48 views

PSET 1 Credit; Sometimes Check50 works and other times it doesn't

Why does Check50 work for certain credit numbers and not others? I ran debug and found that for some credit numbers and not others it may randomly be always one away from a multiple of 10 preventing ...
0
votes
2answers
179 views

Can't submit or check

I'm trying to upload my assignment, but I keep getting the same error whenever I run the check50 or submit50 command: "Make sure your username and/or password are valid and submit50 is enabled ...
0
votes
2answers
56 views

pset 1 - cash problem - No errors, am rounding, but still not always correct amount of coins

I'm having trouble finding out where the problem with my code is on the Cash problem in the CS50 problem set 1. In the other questions for this problem on this forum it often seems to be the round() ...
0
votes
2answers
29 views

I cannot get the CS50 IDE to run clang for lesson 1

While trying to follow along with the professor during lesson one, I cannot get the CS50 IDE to run clang. I have tried renaming the file, restarting the program, and deleting and starting the code ...
0
votes
1answer
20 views

Why doesn't my code give me an output?

So I am very new to CS and I have been working hard twisting this code around in my mind trying to figure out why nothing happens when I run the program. It compiles fine, but whenever I put in any ...
0
votes
1answer
43 views

Coin count off by 1 in cash

When I input an amount into the program cash, it gives me one more coin than I should have and I'm not sure how to fix it #include <stdio.h> #include <cs50.h> #include <math.h> //...
0
votes
1answer
85 views

I keep getting “expected EOF” when I use check50

this is the message identifies 4111111111111113 as INVALID expected EOF, not "INVALID" this is the code #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
21 views

My code is not compiling

my code isn't compiling and i don't understand the error message #include <cs50.h> #include <stdio.h> #include <string.h> #include <stdlib.h> bool checksum(string credit); ...
0
votes
1answer
217 views

CS50W - Wiki with Django - I want to edit a wiki entry, but I don't know how to send the default value to the template if I use Django forms

I've tried to do this: class editPage(forms.Form): title = forms.CharField() textContent = forms.CharField(widget=forms.Textarea(attrs={'class' : 'textContent'})) def edit(request,name): ...
0
votes
1answer
15 views

When I multiply my array by 2 it doesn't give expected value

Also, please when I try to add "firstnumsum", it doesn't give expected value and I don't know what to do. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
49 views

PSET1 Cash - less comfortable - errors only for 0.41, 0.15

I hope you can help me with the PSET1 task - cash - less comfortable. Here is my code but I cannot figure out why - when testing the code - only 0.41 and 0.15 deliver wrong outputs (8 instead of 4 and ...
0
votes
1answer
45 views

i don't know what's wrong with my code. Trying to convert from string to long

INPUT int main(void) { long long cardnumber, calc; string credit[0]; string nonnumeric; //long long calc = card number; int countcardcharacters = 0; long long c; //user input do { credit[0]= ...
0
votes
1answer
31 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 ...
1
vote
2answers
107 views

pset1 (mario, more) - problem with unwanted leading spaces

This is what check50 gives me: > :( handles a height of 1 correctly > expected ""# #"", not "" "\n"# #"" > :( handles a ...
0
votes
1answer
42 views

Error Code - Use of undeclared identifier in PSET 1, Mario

An error code popped up while trying to compile my code, saying that the variable n had not been declared earlier. It had been declared however at the beginning. Here is the code and the terminal ...
0
votes
1answer
31 views

Query related to Mario program(more) in CS50 pset1

I can't figure out the problem in my code, it successfully creates a pyramid but doesn't reprompt when value other than 1-8 is entered, also it gives a space before printing the pyramid, causing ...
0
votes
1answer
28 views

CASH issue - help needed

I've been struggling with this for a month now so any help will be appreciated. The program just returns the value of input, so although there are no errors in compiling, it doesnt actually produce ...
0
votes
1answer
17 views

My program doesn't run when i close the condition's range. When i leave the range open it does't give the answer i want

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; int cents = 0, coin_number = 0, quart = 25, dime = 10, nickel = 5, penny = 1; //...
1
vote
1answer
27 views

Making code neater: a way to reduce repeated logical operators?

For CS50 pset1 Credit I'm using repeated logical-OR operators (||) to work out the validity and card brand of a credit card number. When I evaluate the style of my code using style50 it says to insert ...
0
votes
1answer
49 views

This is my code for cash

This is my code for cash idk what I did wrong cuz when I compile it, it gives me a decimal of the number I put in instead of a whole number representing how many coins. Idk what I did wrong. #include &...
0
votes
1answer
37 views

My code does what I want it to do, but I get errors with check50 (PSET1, MARIO, LESS)

When I run my code in the terminal it gives me the correct response. However, check50 indicates there is an issue with my spaces. I have spend 2 days looking at it but I dont know whats wrong. INPUT /...
0
votes
1answer
35 views

pset1 less greedy - keep on getting errors

I have added a first version of my code, however it is unable to compile and I just cannot figure out why. INPUT #include <cs50.h> #include <stdio.h> #include <math.h> int main(void)...
0
votes
1answer
62 views

cash less comfortable

I've been working on my cash problem but it keeps giving me error on the code especially the variables and I don't know why.

1
2 3 4 5
22