Questions tagged [pset1]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
72 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
2answers
144 views

cs50 pset1 mario.c stuck

I am stuck on cs50 pset1 mario. Here is my code: #include <cs50.h> #include <stdio.h> int main(void) { int height; do { height = get_int(); } while ( height < 0 || height > 22 )...
0
votes
1answer
58 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
200 views

Pset1 Cash Understanding modulo operator and while loops

I'm trying to set up my solution to the Cash problem using modulo. The input seems to be working correctly so far. It only accepts positive numbers through the do..while loop. The problem I think I ...
0
votes
1answer
157 views

PSET1 - Credit HELP

I am now working on the first part of credit, and is currently checking the validity of the number given. I separated it into two parts, one where I summed the doubled digits, and one where I summed ...
0
votes
2answers
104 views

Pset1: Problem: expected “##\n”, not “ ##\n”

Program works like a charm but still get these errors in the end when running the check. Could not figure out the issue. Why ? Thanks
2
votes
2answers
1k views

PSET1:: Mario More Comfortable :: confused about check50 output

I am sorry if I miss something obvious here, but I am an absolute beginner. I get the following output from check50, which I am confused about: I will attach my code below, but my output for 2 is: ...
0
votes
1answer
40 views

running into a do…while loop issue

I am having an issue with output from a do while loop. Code is below do { printf ("Height:"); height=get_int(); } while (height < 0 || height > 23); it works for negative numbers ...
0
votes
1answer
27 views

Another question about how my 'for' parameters are affecting my output?

After some manipulation and trial/error, I finally got my code to output the desired spacing for the half pyramid. However, I am having trouble understand one of the relationship between my condition ...
0
votes
1answer
42 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

Can someone help me understand what I am manipulating in the for statement?

Through trial and error, I have been able to get my pyramid close but not quite where it needs to be. I started with the hashes because it was difficult to interpret spaces in the output terminal and ...
0
votes
2answers
101 views

pset1: credit keeps printing INVALID for valid card #s

My solution to credit in pset1 compiles without issue but prints INVALID regardless of whether or not the card number is valid. I've attempted to diagnose the problem to no avail. I used string ...
0
votes
1answer
67 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
3answers
102 views

Incorrect input of value yields incorect output in Cash task at PSet 1

My code #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float sum; int sumInt; // Check user input and convert it to cents do { //eprintf("about to ...
0
votes
2answers
32 views

Where my bug for problem set 1?

I'm seriously not sure what i'm doing wrong, i just copied and pasted the template from the problem.
-1
votes
1answer
52 views

pset1 ---------— mario less

I am not understanding as to what is expected when it says " rejects a height of -1 expected program to reject input, but it did not" what is "reject input"? please help
0
votes
1answer
70 views

Errors while check50 in Pset1 mario less, expecting suggestions

I am getting following errors with check50. Need help to understand which part of my code cant handle these situations. :( handles a height of 1 correctly expected "##\n", not "" :( ...
0
votes
1answer
217 views

Trying to make cash.c from pset 1 without mod

So I've made this program with modulus and it made sense to me, but when I ran it I got an error message saying I can't use mod on floats. Since then I've been trying to replace this: change = ...
3
votes
2answers
145 views

Which loop can be replaced for nested for loops for PSET 1 (Mario More Comfortable)?

According to the cs50 style guide for C, more than 3 variables for iteration is not a good practice. I have done Pset 1 (Mario more comfortable) with 5 for loops, so it has 5 iterations variables. Is ...
0
votes
1answer
117 views

about pset1 credit

I'm working on pset1 credit. To identify the valid credit card number. First I ask users to input a long long, which I made it a int so that i can make sure it fit the first requirement(any number > 0)...
0
votes
1answer
61 views

What's wrong with my Credit code? works for some and doesn't for the others

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardNumber; char cardNumberStr[16]; char cardNumberArray[16]; int i, numberOfDigits; int sum = 0; ...
0
votes
1answer
84 views

CS50x Cash Question

I'm working on the "cash" problem from CS50x pset1, and I'm having trouble finding the problem with my code. Most of the answers are correct, but when I input "0.56", the return value is "5" which is ...
0
votes
2answers
362 views

No rule to make target `mario1'. Stop

any advice would be great. Thanks!
0
votes
2answers
3k views

How to print a long number in C?

Hello I am very new to C but have some experience with python and would like to know how to print the outputs for the credit.c so I know what I am dealing with. I have this code and when I get to the ...
1
vote
2answers
50 views

Cs50 pset1 mario syntax errors or wrong code

Okay so I've tried multiple ways to get my blocks to simply create columns and rows first before adding spaces (though I've tried). I've watched and rewatched the lecture multiple times but I can't ...
0
votes
1answer
231 views

pset1 credit assignment

I assume anyone looking at this question knows the assignment but to recap I need to write a program that will identify different CC#s—AMEX, MC, VISA, or Invalid. Since all these CCs range from 13-16 ...
1
vote
2answers
188 views

I can´t get (pset1) greedy/cash.c pennies to work properly!

i´ve been trying to figure out what is wrong with my code for the pset1 cash or greedy program, i know about float imprecision but when i print the last value for "ch" it prints .01000, thus meaning ...
0
votes
1answer
388 views

Receiving 'error: expected expression' for code inside if statement (pset1)

Originally, my if statements looked like these (please note that I didn't really write them one after the other like this): if (counterCardLength == 15 && FindFirstTwoDigits == 34 | 37) if (...
0
votes
1answer
942 views

pset1 | error: invalid operands to binary expression ('long long *' and 'int')

Here are snippets of my code: long long card = get_long_long(); long long *FindLength = *card; while (FindLength != 0) { FindLength = FindLength / 10; counterCardLength++; } And ...
0
votes
1answer
4k views

pset1 Error: indirection requires pointer operand

Here is a snippet of my code: long long card = get_long_long(); long long *FindLength = *card; long long *FindFirstTwoDigits = *card; And here are the errors: credit1.c:8:29: error: indirection ...
0
votes
2answers
136 views

:( mario.c compiles this looks like a compiling error

I have written the code for mario- less comfortable. But when I run check 50, it gives a error which states: :( mario.c compiles I am not being able to understand as to what is wrong.
0
votes
1answer
32 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
36 views

CS50 Problem set 1 - my code is weird and maybe a bit hacky, need help!

I'm stuck on problem set 1 - less comfortable. This is what I have: #include <cs50.h> #include <stdio.h> int main(void) { float change; int numberofcoins = 0; do { ...
0
votes
1answer
52 views

Pset1: Error when trying to assign single digits of int variable to array using for loop

I'm currently working on Credit. I'm trying to find the first two digits of the card number using a for loop. I've created an array named firstdigits with two elements. Then I've created a for loop to ...
1
vote
1answer
94 views

PSet1 Cash returning implicitly declaring library function 'roundf' with type 'float (float)'

I am currently working on the pset1 greedy (cash) project. I am so close to finishing and I only have one more thing to complete before I can submit it as correct. I am working on rounding the initial ...
0
votes
2answers
126 views

Why isn't my block on pset1 turning into a staircase?

I am currently working on pset1 Mario, less comfortable. I am running my c to turn the hashtags into a staircase, but when I run the code, it is only a block. What is wrong with my code? Thank you all ...
1
vote
1answer
773 views

Problem with rounding for pset 1 cash

Desperately need help for pset 1 cash! My code failed 2 of the check50 tests: :( input of 23 yields output of 92 :( input of 4.2 yields output of 18 I believe it's a rounding problem, but I've been ...
1
vote
1answer
135 views

For mario less comfortable, I did it correct but i do not understand the logic behind it

my code for mario less comfortable is correct. But I got the answer by trying out different value multiple times. And after I finally got the correct answer, I do not understand the logic behind it. ...
0
votes
1answer
559 views

Problem with my credit code

Just finished working on credit and after testing it with the number in pset1 page it was working well and I have tested it against other numbers too the problem is when I ran check50 it said that ...
0
votes
1answer
301 views

Credit - Why Does it Fail Passing check50?

When sending my code to Check50, all the Credit Card checks go through ok but one: :( identifies 4062901840 as INVALID expected "INVALID\n", not "VISA\n" But doing the steps: 1) Multiply every ...
0
votes
1answer
59 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
49 views

my code for pset1/mario/more not through by check50, can any one plz check and advice. thank you

#include <cs50.h> #include <stdio.h> int main(void) { int n; do { n = get_int("Height: "); } while(n <= 0 || n > 1); // Print out first row for(...
0
votes
1answer
598 views

Stumped on pset1 cash.c, please help me learn

I'm trying to create a solution for pset1 cash.c, the code below is not meant to be the final implantation, just a cursor to figure out the problem. When I run this code it works for values .01 to .05 ...
0
votes
1answer
69 views

Incorrect mastercard number in pset1 cs50 2018 [duplicate]

according to Luhn's algorithm, 5105105105105100 is invalid as the total comes out to be 25, but the check50 cs50 says its valid. and in places, they starting to double the digits from the first digit ...
0
votes
1answer
676 views

PSET1: Can't check hello.c

Doing on https://ide.cs50.io typing check50 cs50/2018/x/hello hello.c in ~/workspace/pset1/hello/ $ And got Uploading.. Unexpected token <
0
votes
1answer
196 views

pset 1 - mario (less) no output

I've typed make less in the terminal but nothing happens. Here's my code: #include <stdio.h> #include <cs50.h> int main(void) { // Ask user for height int height; do { ...
-1
votes
1answer
73 views

Im having trouble compiling hello.c.. What am I missing?

Here is the cs50 hello.c file as is. Why wont it compile? #include <cs50.h> #include <stdio.h> int main(void) { printf("hello, world\n"); }
0
votes
1answer
205 views

PSET 1: Mario help (Drawing pyramid)

Stuck on Pset 1 - drawing the pyramid (prompting the user for a number between 0 and 23 working fine). When I try to execute this program, it goes crazy- is there something wrong with my for loops? ...
0
votes
1answer
65 views

i've tried for a week to compile this. cs50 mario.c please help

#include <stdio.h> #include <cs50.h> int main (void) { int n = get_int("Height: "); for (int i = 1; 1 < n; i++) printf("#\n"); }
1
vote
1answer
75 views

Incorrect mastercard number in pset1 [duplicate]

by lunh algoritm result of calculating 5105105105105100 will be 25 and it means that this card is invalid, but check50 output this: :( identifies 5105105105105100 as MASTERCARD expected "...

1 2 3
4
5
22