Hot answers tagged

4 votes
Accepted

What is the difference between ++i and i++?

x++ - Post-increment operator ++x - Pre-increment operator In short, x++ - x is incremented after the current statement is evaluated. ++x - x is incremented before the current statement is evaluated. ...
user avatar
3 votes
Accepted

Do video shorts include any content that the readings don't?

Although the shorts are still sufficient for the course needs, the recommended readings address these topics probably in more details and cover more things than the shorts, but the shorts are more to ...
user avatar
  • 17.3k
2 votes
Accepted

Where is the CS50 style guide document?

Styles are important because they specify good coding habits, which gives you comfort when working in a team, as everyone would be following the same convention, so it will be easier for others to ...
user avatar
  • 3,316
2 votes

Subtitle files for problem set 0 videos

If you're using edx, the videos posted on there have subtitles. Go to Week 0 > Shorts (or click here) and click one of the options on the top bar. I don't see the fourth video listed, however. ...
user avatar
  • 481
1 vote
Accepted

Pset2 Functions video - Valid triangle solution

What I think you are doing wrong is, you are checking if an array is less than or equal to 0. What you should be doing is indexing into the array. Then it would be checking the float values. while (...
user avatar
1 vote
Accepted

Cannot Compile Due to Error in cs50.h

The function signature has changed. From the CS50 Programmer's Manual char *get_string (const char *format, ...); DESCRIPTION Prompts user for a line of text from standard input and ...
user avatar
1 vote
Accepted

Switch(c) undeclared identifier

Simply put, c doesn't exist because it was never declared, and no value has been assigned to it. I could explain in detail, but the following site has already done it very nicely, including an ...
user avatar
  • 63.1k
1 vote

I don't understand how the collatz(n) recursive function works

Based on the Collatz Conjecture, all values of n will eventually reach the value of 1 and fall into the pattern of 1, 4, 2, 1, 4... continuing forever. Therefore we want to have a base condition to ...
user avatar
  • 11
1 vote
Accepted

C data types and format specifiers

INT02-C. Understand integer conversion rules Conversions can occur explicitly as the result of a cast or implicitly as required by an operation. Although conversions are generally required ...
user avatar
1 vote

C data types and format specifiers

Looks like C is (internally) casting the constant 2 (or probably more correctly, the result of n - 2) as an int since that is the essential difference between the two printfs. You might search the ...
user avatar
1 vote
Accepted

Week 3 Binary Search Video Short question

in case we have a single element left in the array, max and min would be equal. the midpoint is calculated, and we check whether array[midpoint] is equal to the value we're looking for. if the ...
user avatar
  • 17.3k
1 vote
Accepted

Source code from the Week 7 short, "Singly Linked Lists"

It can be found here. In general, edX: You can find the source code in Courseware tab > Week X > Lecture / Lecture, continued > scroll down to below the video under Source Code. Everyone: You can ...
user avatar
  • 481

Only top scored, non community-wiki answers of a minimum length are eligible