Questions tagged [code]

The tag has no usage guidance.

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

What do you think about my code here?

#include <cs50.h> #include <math.h> #include <stdio.h> #include <stdlib.h> int main(void) { long long credit_num; credit_num = get_long_long("credit number: "...
انس رفعت OR. ANAS REFAT's user avatar
-1 votes
0 answers
14 views

cash does not work anymore

Yesterday, my code worked. Today, the code doesn't work anymore. Both times I tried check 50. Yesterday everything was alright but today it wasn't. What happened?
user40089's user avatar
0 votes
1 answer
48 views

practice problems week 3. Sort temperature. And my result is all the temperature is sorted but the name of the city is not

void sort_cities(void) { // Add your code here for (int i = 0; i <= NUM_CITIES - 1; i++) { if (temps[i].temp < temps[NUM_CITIES - 1].temp) { int temp = ...
doan nathan's user avatar
0 votes
0 answers
57 views

I don't understand the answer to the pset3 atoi practice problem

#include <cs50.h> #include <ctype.h> #include <math.h> #include <stdio.h> #include <string.h> int convert(string input); int number = 0; int main(void) { string ...
Harr's user avatar
  • 25
0 votes
1 answer
10 views

Hi all, there is something wrong with my code below , I cant get my head around the compiling errors thanks!

#include <stdio.h> #include <cs50.h> int main(void) { //Prompt for start size int start; do { start = get_int("start: "); } while (start < 9 ); // Prompt for end size int end; ...
Geoff's user avatar
  • 11
0 votes
1 answer
11 views

Getting " error: declaration shadows a local variable" but i don't know why

int wordsize = atoi(argv[1]); int status[wordsize]; for (int b = 0, wordsize < b; b++) { status[b] = 0; } The error happens specifically at the word "wordsize" in the for loop. I'm ...
Harr's user avatar
  • 25
0 votes
0 answers
14 views

cs50 string not registering

stack.imgur.com/OShHG.png I'm following along with the cs50 course why is my string not registering and changing color like the example code?
CONEDIGGITY's user avatar
0 votes
1 answer
225 views

Getting the error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type] and i don't know why

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> bool only_digits(string s); int main(int argc, string argv[]) { if (...
Harr's user avatar
  • 25
0 votes
1 answer
17 views

Getting error expected ')' and I don't know why

if ((word{i} >= 'a' && word{i} <= 'z') || (word{i} >= 'A' && word{i} <= 'Z')) { while (points{j} < word{i}) { j++; } ...
Harr's user avatar
  • 25
0 votes
1 answer
13 views

How do I combine variables and words in a sentance?

printf("%i\n", quarters, "quarters,", "%i\n", dimes, "dimes,", "%i\n", nickels, "nickels", "%i\n", pennies, "pennies.");...
Harr's user avatar
  • 25
0 votes
0 answers
75 views

I get 50% at Final Project

I just uploaded my final project - Note taking - and somehow get 50%. I followed all instructions: uploaded the video, made a README file (about 120 word), but still nothing happened. Do you have any ...
Zaman Kazimov's user avatar
0 votes
1 answer
54 views

The "Code Command" did not work for me in "code mario.c" - August 28th, 2022

This is my first post here. I'd like to know why the "code command" did not work for me (code mario.c). I was trying to create a file as the professor did. This command is used by the ...
Anderson's user avatar
0 votes
1 answer
331 views

How do I get rid of the "expression result unused" error?

I am trying to get it to where if input "n" and "x" are the same number it will display "years = 0" if not it will run else statement. Instead it was running both the if ...
Selena H.'s user avatar
0 votes
1 answer
112 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 ...
Valentina Rivas's user avatar
1 vote
2 answers
42 views

Does somebody explain %d, %s, etc

Couldn't find it either googling it or in the lectures so far. Does somebody have the complete options and what they are for? Thank you very much.
333PPP's user avatar
  • 29
0 votes
1 answer
19 views

I have a problem regarding " Condition"

Well, I am learning the C program. When I wrote a command I got an error message but I don't know why. The code runs like this:- if (answer == "something") [here, the 'answer' is a string ...
Artinxt's user avatar
0 votes
1 answer
18 views

Trying to do pset 2, but it doesn't even accept my input. What am I doing wrong?

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <math.h> int check(int c, string key); int main(int argc, string argv[]) { int ...
Lakshya Dugar's user avatar
0 votes
2 answers
518 views

how do i write pesudocode.txt for Mario? (less comfortable)

After I input: mkdir ~/pset1/mario its asking me to write pseudocode.txt and i am not sure how i can do that. I've tried inputting the pseudocode.txt and that gives me "command not found"
Iris A San Juan's user avatar
0 votes
1 answer
95 views

Syntax Highlighting Error

I am working on my mario problem. I write my code in C, but it's not getting highlighted, meaning the program doesn't understand it. How can I get it to understand my code? for example #include is in ...
Tisha Rajput's user avatar
0 votes
1 answer
182 views

Pset7 Movies Q12: I don't get what's wrong

I can't figure out why my pset7 movies Q12 code isn't working. Can anyone tell me why? Here is my code: SELECT DISTINCT title FROM movies, stars, people WHERE movie_id IN (SELECT movie_id FROM stars ...
Miguel's user avatar
  • 1
0 votes
1 answer
431 views

Error: use of undeclared identifier 'j'

My code looks fine but "make mario" insists that "Error: use of undeclared identifier 'j'". #include <cs50.h> #include <stdio.h> int main(void) { int n; do { n = get_int ("Height: "...
Firestar464's user avatar
0 votes
1 answer
72 views

Mario Less Loops doubt and code review

I have attempted the PSET 1 of 2020 CS50x and have a couple of doubts. Could someone check if the following code for Mario less one is correct. If it is I also had a question that what should I put ...
Raquel's user avatar
  • 1
0 votes
1 answer
15 views

Why is the value 16,432 appearing, and why is it getting reduced each time I run the program?

So I was following along the week one lecture, and I was trying to replicate the average-taking program, when I made a slightly silly mistake- I used the average function within the for loop. #...
Pranav Nair's user avatar
0 votes
1 answer
270 views

Greedy(less comfortable) questions/thoughts/input/advice on my programm

Hello I am relatively new to programming and C in general. I have left the comments next to the points I have questions to, please don't give me any solutions, as I really want to learn and ...
Der Traumwanderer's user avatar
0 votes
2 answers
127 views

Help! CS50 Error message not making sense at all

I am in week 1 on CS50 2017, and in the lecture he presents a code written as follows: #include <cs50.h> #include <stdio.h> int main(void); { int n = 0; while (true) { ...
Austin Tyler Cunningham's user avatar
0 votes
1 answer
42 views

pset6 - greedy doesn't print answer- just returns the input. Where have I gone wrong?

import cs50 while True: print ("O! Hail!, How Much Change Is Owed?") n = cs50.get_float() if n >= 0: break q = 25 q1 = 0 d = 10 d1= 0 ni = 5 ni1 = ...
doublestanding's user avatar
0 votes
1 answer
346 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. ...
KhalidMukadam's user avatar
0 votes
1 answer
46 views

why doesnt this code print the number of bottles of water used? it only stops after prompting user for number of minutes

include include int main(void) { printf("duration of shower in minutes :\n"); int m = GetInt(); printf("minutes : %i\n", m); int b = b; int bottles(int b); { ...
law jia hua's user avatar
3 votes
4 answers
1k views

Problem with format codes

I'm trying to get cs50 IDE to print the size of char, double, float and int. This is what I wrote: #include <stdio.h> int main(void) { char c; double d; float f; int i; ...
TinaVr's user avatar
  • 31
0 votes
1 answer
66 views

Whats wrong with Vigenere code

This is the cleanest way i can think of of implementing vigenere, but i don't see whats wrong.. the code should work fine.. but its not. Please help string k = argv[1]; int keyLength = strlen(k); int ...
Nilabha Chatterjee's user avatar
0 votes
1 answer
66 views

week7 lecture2 source code speller.php not found

David showed the php version of speller.c but I can't find the code neither on edx, nor on cs50.harvard.edu https://cs50.harvard.edu/lectures/7/w/src https://courses.edx.org/courses/course-v1:...
Vitale's user avatar
  • 235
0 votes
1 answer
127 views

What's wrong with this code for the Caesar Cipher?

I created this Caesar Cipher program, but for some reason, I can't find its bug. Here is the code. It compiles, but it just prints out the same thing I enter, for any key. #include <cs50.h> #...
Epic Defeater's user avatar
0 votes
1 answer
37 views

server gives same error code with different conditions

Below I'm validating the request-line conforms to the spec (printf statements were telling me the errors were from these if statements). The first 3 blocks worked fine independently and together. (e....
Norcim133's user avatar
1 vote
3 answers
510 views

Help with pset1 mario, I don't understand what's wrong with my code

Whenever I do check50 on this code, it gives me lots of errors, and I'm not sure what I'm doing wrong.
daenadamonse's user avatar
-2 votes
3 answers
33 views

what is wrong in this program?

#include<cs50.h> #include<stdio.h> /** * program to check my name */ int main(void) { printf("tell me your name\n"); string names=GetString(); if (names = "peter") printf(...
peter alon's user avatar
1 vote
2 answers
59 views

Submitting Source Code?

When I submit a pset it says I need to submit a source code as well...where can i find that? I think thats why my psets arent getting graded. Please help
Ani's user avatar
  • 61
1 vote
1 answer
87 views

code doesn'work, please help

I tried to write this little piece of code, but I couldn't figure it out entirely. Can someone help me with the missing parts? #include <stdio.h> #include <cs50.h> int main(void) { ...
newbie's user avatar
  • 11
0 votes
1 answer
630 views

How do I unzip source code?

I've downloaded the Source Code files for Lecture 2 to the jharvard directory. How do I unzip them?
Mkolanda's user avatar