Questions tagged [pset1]

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

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

Week 1 - Problem concerning question on 'credit'

#include <cs50.h> #include <stdio.h> int main (void) { //User's Input long n = get_long("Number: "); int sum_of_odds = 0; int sum_of_evens = 0; int count = ...
0
votes
1answer
4 views

week 1 no workspace?

I'm trying to get through the first 15minute of the lecture and already lost :( I tried to go through other questions that recommends to find the right ~workspace and ~pset1 but I don't know how to go ...
0
votes
1answer
14 views

function output?

I can't get this function to output the desired value of 0.07. #include <stdio.h> #include <cs50.h> #include <math.h> float i = 1.32; float quar_val = 0.25; int func(float val, ...
0
votes
1answer
19 views

CS50 problem set 1 CREDIT works sometime but not always

I am very new at coding and taking CS50. I am currently working on the credit problem in week 1. I finished coding but when I ran check 50 my code only seemed to work for some of the card numbers and ...
0
votes
0answers
10 views

problem with credit with this numbers (369421438430814 & 5673598276138003)

I just finished solving the credit problem and regularly used check50 to see my results, and then this happened. check50 sees that these numbers : 369421438430814 5673598276138003 are invalid, even ...
0
votes
1answer
25 views

How do I change if/else if statements into a loop?

I cannot figure out how to change the following code into a loop. This is just a portion of a larger code where n is defined by user input. How do I create a loop that adds one "#" to each ...
0
votes
1answer
22 views

Recalling the function for output changes the input

#include <stdio.h> #include <cs50.h> #include <math.h> int procedure (int array[] , int length); int input_length ( long input ); int main (void) { long card = get_long("...
0
votes
1answer
25 views

Credit (Pset1) - Do While Loop

I am still really new to C and programming in general(just started a week ago) and I'm having difficulty with the do while loop. My code doesn't run beyond while (ccNUM < 0);. I tried running ...
0
votes
0answers
21 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
2answers
31 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
0answers
20 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. :( ...
1
vote
1answer
18 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
26 views

I have to enter any letter to get the result

I am currently doing the problem set 1 credit in cs50 program. I managed to write the code. It's compiles fine however once I enter the credit card number it stops, i must type any letter to get the ...
0
votes
1answer
36 views

Is there a way to replace the whitespace in the url whose part is some user input? i.e. User input contains whitespaces Pset1 (Wiki)

I'm doing a project of CS50's Intro to Web Programming with Javascript and Python(Pset1 : Wiki). While creating a new entry/page I'm asking the user for a title and content for the page. After which I'...
0
votes
1answer
18 views

pset1 credit; buffer overflow when converting to char array

My initial idea for the credit problem was to convert the long from get_long into a char array, in order to obtain something iterable to get each digit for Luhn's algo. I recognize that this could be ...
0
votes
1answer
57 views

Credit (Pset1) - Checksum problem

so I have a problem with the Credit exercise from pset1. I updated my code today after realizing that I didn't split up the digits of the product of the current digit in the card number and 2 and ...
0
votes
1answer
28 views

Pset1 “cash” question

this is my first question here so sorry if I do it wrong. My code compiles (it´s not finished yet), and it prompts, but when I run ./cash and type a number, It always gives me 0 coins, no matter what ...
0
votes
3answers
21 views

:( handles lack of argv[1] failed to execute program due to segmentation fault

if (argv[1] == NULL) { printf("Usage: ./caesar key\n"); return(1); } this is the solution before the program received the first statement validate null
0
votes
1answer
39 views

the code which is expected and my actual code are the same but check50 see it as incorrect LAB1

#include <cs50.h> #include <stdio.h> int main(void) { // TODO: prompt for the start size int n; do { n = get_int("start size: "); } ...
0
votes
1answer
67 views

My do-while loop does not work

do { number = get_long_long("What is your credit card number? "); } while((number < 1000000000000) || (number >= 10000000000000000)); This loop is not accepting inputs. I do not ...
0
votes
1answer
39 views

Problem set 1, Cash executuion issue

My code is as following: #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { //prompt for change float a = 0; int c = 0; ...
0
votes
1answer
40 views

make mario won't work but i'm in the correct directory

make mario won't work but I'm in the correct directory. I haven't even started writing the solution properly as I'm stumped on getting it to compile. Any suggestion? I tried restarting the IDE and ...
0
votes
1answer
54 views

How to submit Pest1 with SUBMIT50?

When I try to submit Pset1, in the terminal, it always does this: submit50 cs50/problems/2020/x/mario/less Connecting...... Authenticating..... GitHub username: A***********8144 GitHub password: ******...
0
votes
2answers
43 views

A problem with my code in PSET 1 Mario less comfortable

I think I have got everything right except when my program is run it prints an extra line without any hashes, can anybody point out or correct my arithmetic (or the code)? Here's the code: #include<...
-1
votes
1answer
43 views

CS50 IDE returns - bash: command not found

I get the following error while trying to execute a command. Example: ~/pset1/hello/ $ hello bash: hello: command not found 'make hello' worked fine: ~/pset1/hello/ $ make hello clang -ggdb3 -O0 -std=...
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
4answers
36 views

PSET1 So my code executes and prompt me for the money owed but that's it..nothing happens. Can someone point me in the right direction

I don't know what I'm doing wrong I get no errors. I feel like my code #include <cs50.h> #include <math.h> #include <stdio.h> int main(void) { float x; float a = 25; float b = 10; ...
0
votes
2answers
57 views

pset1 mario (less comfortable), expression error

I keep getting 'expression error' when I try to compile my code; any help would be appreciated. Code is as follows: #include <stdio.h> #include <cs50.h> int main(void) { // prompt ...
0
votes
2answers
45 views

Getting error on cs50 problem set 1 mario “handles a height of 1 correctly,timed out while waiting for program to exit”

Getting error on cs50 problem set 1 Mario "handles a height of 1 correctly, timed out while waiting for program to exit" Here's my code: #include <stdio.h> #include <cs50.h> int ...
0
votes
1answer
33 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
25 views

PSET1 Cash Outputting negative number?

I have a very bizarre problem I am experiencing. When I input any number the output by my program is as such: coins: 2 mQ + mD + mN + pN = -1055516176 When I run the program again it outputs nothing ...
0
votes
0answers
22 views

Help, doe not working - cash [duplicate]

Can someone please help me, as much as I think it should give the least amount of coins needed but it is not.
0
votes
1answer
39 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
38 views

Can you tell me my mistake

Please help, I don't know where the problem is.
0
votes
1answer
39 views

Pset1 Credit - Why is my code bypassing the Floor function inside If statement?

Here's my code- int f_1 = floor(N / 1000000000000000); int f_2 = floor(N / 1000000000000); int f_3 = floor(N / 100000000000000); int f_4 = floor(N / 10000000000000); if (...
0
votes
1answer
50 views

Pset1 - Mario less printing 2 extra spaces

I have submitted mario.c and while it printed the pyramid, it is printing 2 extra spaces in front of each hash row. What am I missing here? #include <cs50.h> #include <stdio.h> int main(...
0
votes
1answer
36 views

pset1 credit solution. code not working but there is no bug

I wrote this code and I can "make credit". However, when I tested it with numbers, it doesn't work. Please see my code below. #include <cs50.h> #include <stdio.h> #include <...
0
votes
1answer
46 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
0answers
25 views

Could anyone explain the error message?

#include <cs50.h> #include <stdio.h> #include <math.h> int main (void) { float dollar; do { dollar = get_float("Enter your change"); } while (...
0
votes
1answer
29 views

Could someone explain to me how curly braces work?

#include <cs50.h> int main (void) { int height; do { height = get_int ("Enter Height"); } while(...
0
votes
1answer
32 views

Im having a real hard time

I have a cash directory in which my source code cash.c and machine code cash are within. Why does this pop up? $ cd workspace $ cd cash.c $ make cash clang -fsanitize=signed-integer-overflow -...
0
votes
2answers
36 views

Hello everybody : ) Can you help me out?

$ clang cash.c /tmp/cash-94cd4e.o: In function main': cash.c:(.text+0x1c): undefined reference to get_float' cash.c:(.text+0x44): undefined reference to `round' clang: error: linker command failed ...
0
votes
2answers
45 views

pset1 cash THESE 2 ERRORS DROVE ME WILD help a newbie out, I will send you good vibes in return

error: expected identifier or '(' error: expected ';' after top level declarator int main (void) code #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) float ...
0
votes
1answer
62 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
48 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
1answer
48 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
22 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
25 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
18 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
72 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 ...

1
2 3 4 5
23