Questions tagged [pset1]

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

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

Why won't the last line of my code print?

So I am attempting to run this code, but for some reason my final print function is not printing to the terminal. Can you help me figure out what I am doing wrong? #include <cs50.h> #include <...
0
votes
0answers
11 views

Can someone please help me I am trying to find what is it I am doing wrong here in pset1

I am in the dir ~/pset1/hello but it gives the same error again and again it does not show anything in the ls command.
0
votes
1answer
10 views

Credit problem: Opening parentheses not matched with closing

Though it might appear annoying, the program not compiling. To the best of my understanding, there is a closing parenthesis on line 37. Is it some cache related issue? https://drive.google.com/file/d/...
0
votes
1answer
18 views

Function in C: How to create

#include <stdio.h> #include <cs50.h> int main(void) { long creditcardno; do { creditcardno = get_long("enter"); } while (creditcardno < 0); } The above code accepts ...
0
votes
1answer
17 views

Caesar problem. Keep getting error of segmentation

The follow part of code worked perfectly, while I declared variables key_num and plaintext within if{}, but since I declared them outside (cause I need to use these vars later) I get the "...
0
votes
2answers
33 views

Pset1 credit, checksum value gives wrong value

I find myself stuck on credit. Can't figure out where the problem lies in my logic. Checksum gives 4 where it should give out 0. Ideas appreciated. //calculate checksum value int sum1, ...
0
votes
1answer
12 views

make: Nothing to be done for 'Mario'

I am confused.... :( Am I in the wrong directory?
0
votes
1answer
17 views

Pset1 - Population

I'm having trouble with the last bit of code, where the years are calculated and printed. The loop seems to run once fine. If I put in something like 12 to start and want to get 13 it will give me the ...
0
votes
0answers
21 views

Error: use of undeclared identifier on an apparently declared variable

#include <stdio.h> #include <cs50.h> int main(void) { long creditcardno; do { creditcardno = get_long("enter"); } while (creditcardno<...
0
votes
1answer
97 views

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm getting this error when I try to compile pset1 cash assignment, can someone please help? help50 also doesn't work so I really don't know what the problem is. enter image description here
0
votes
0answers
35 views

CS50 Pset Credit

After working on this problem for 5+ hours I was able to get the code working. After I summitted it, I looked at other peoples solutions, and most of them were very different than mine. Is the style ...
0
votes
1answer
16 views

make: *** No rule to make target 'cash'. Stop. error

I'm trying to compile this assignment but I keep receiving this message I read that the file name should match the folder name but the file's name is cash.c and it is in a folder named cash under the ...
0
votes
1answer
266 views

CS50 LAB 2- SCRABBLE

Hi, anyone can help me. I can't get the result I need for this code. I need to compare words whether player 1 or 2 wins. I only get result for tie. I dont know which line to fix. I new in learning ...
0
votes
1answer
40 views

What does it mean when it says "error: expected ';' in 'for' statement specifier"? It is referring to " for (k <= n; k--)" ... what's wrong with that?

This is for the Mario pyramid. I am having trouble with it. I finally got the left sided one working but I can't figure out how to put my .s and my #s on the same line when trying to make the side ...
0
votes
1answer
37 views

pset1 cash please help I'm stuck

can someone tell me why my code doesn't output properly? # include <stdio.h> # include <cs50.h> # include <math.h> int main(void) { int dollars; do { dollars = ...
0
votes
1answer
32 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
8 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
18 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
29 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
1answer
32 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
35 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
24 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
27 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
1answer
36 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
41 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
28 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
23 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
27 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
40 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
23 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
64 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
47 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
33 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
42 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
68 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
42 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
41 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
136 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
45 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
75 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
31 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
37 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
60 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
47 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
38 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
29 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
43 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
40 views

Can you tell me my mistake

Please help, I don't know where the problem is.
0
votes
1answer
40 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 (...

1
2 3 4 5
23