Hot answers tagged

4

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. Huh? Well, lets say we have a function called foo which has a local variable x: int foo() { int x = 0; return x++; } In this function, x is ...


3

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 the point (regarding the problems, week topics or "scoring aim" of the course) than the readings. I didn't go through "all" the shorts and the readings (I ...


2

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 read your code( and vice versa). CS50 has a online Style Guide that has a good description to stylize comments, conditions, switches, functions, indentation, ...


2

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. Found a walkthrough (may be different, though) by browsing the files where the others were posted. You can find the download links for the videos here. You can ...


1

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 (sides[i] <= 0); :)


1

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 returns it as a string (char *), sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n) as line endings. Stores string on heap, but library’s ...


1

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 example that is very similar to your code with all the missing pieces. ;-) https://www.tutorialspoint.com/cprogramming/switch_statement_in_c.htm If this answers ...


1

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 for the correct execution of a program, they can also lead to lost or misinterpreted data. Conversion of an operand value to a compatible type causes no ...


1

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 internet-at-large for "C integer promotion rules". There are a lot of hits on the subject. This might be an interesting place to start.


1

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 previous condition is not true, namely array[midpoint] is NOT equal to the value we're looking for, the algorithm still proceeds further and either sets max to a ...


1

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 also go to http://cs50.tv/2013/fall/ (or whatever semester you're watching), Lecture tab > Week X > Monday/Wednesday > Source Code.


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