R.1 - Review 1 (2026-09-16)
Overview
Chris Bourke reviews material for the first exam, a 25-question multiple-choice test taken at the Digital Learning Commons with a 60-minute limit, one two-sided notes sheet, and a calculator. The programming review builds two C examples: a coordinate program using Manhattan and Euclidean distances plus quadrant logic, and a battery-drain table using loops, piecewise and exponential formulas, math-library functions, compiler warnings, and boundary checks.
Key takeaways
- For a point (x, y), Manhattan distance from the origin is fabs(x) + fabs(y), while Euclidean distance is sqrt(x*x + y*y); use fabs for doubles in C.
- A C program receiving two user-supplied command-line values should expect argc == 3 and parse argv[1] and argv[2], since argv[0] is the executable name.
- Order mutually exclusive coordinate checks from most specific to most general: test the origin, then axes, then the four quadrants.
- A fractional-step loop needs a floating-point time variable and an explicit progress update such as time += increment; otherwise a while loop can run forever.
- Use logical conjunctions to express numeric ranges in C, and use chained if-else branches to choose the correct piecewise formula.
- Clamp battery models at zero where appropriate; exponential decay approaches zero asymptotically, so a small threshold such as 0.00001 can represent practical depletion.
Chapters
- The exam begins the next day and requires students to book and attend an assigned Digital Learning Commons time.
- The test has 25 multiple-choice questions, including code-reading questions such as predicting program output, and allows up to 60 minutes.
- Students may bring one handwritten or typed notes sheet, which can be two-sided, plus a calculator and scratch paper.
- The example reads an XY point and reports its quadrant or axis location along with both distances from the origin.
- Manhattan distance is |x| + |y|, while Euclidean distance is sqrt(x² + y²).
- For the sample point (2.4, 3.9), the Manhattan distance is 6.3 and the point lies in quadrant one.
- A program invoked with two user values has argc == 3 because argv[0] contains the executable name.
- Convert coordinate arguments with atof and store them in double variables; use fabs rather than integer abs for floating-point absolute values.
- Include the math header and link the math library with gcc using -lm; compile with -Wall and -Wextra to surface warnings.
- Check the origin first with x == 0 && y == 0, then check the x-axis with y == 0 and the y-axis with x == 0.
- Classify quadrants using sign tests: positive-positive is quadrant one, negative-positive is two, negative-negative is three, and positive-negative is four.
- Test boundary cases such as (0, 10) and (10, 0), then negate both coordinates to confirm distances stay the same while the quadrant changes.
- The battery example compares linear, piecewise, exponential, and advanced exponential models, starting from 100% charge.
- The linear model loses 10 percentage points per hour; the piecewise model uses different drain rates over 0 to 2, 2 to 5, and 5 to 14 hours.
- The program accepts an ending time and a fractional-hour increment, then prints each model's charge at every sampled time, such as 15-minute steps.
- Parse the ending time and increment as doubles, initialize time at 0.0, and continue a while loop while time <= hours.
- Use chained if-else conditions for the piecewise model; express ranges with logical && because C does not support mathematical chained comparisons.
- Use exp() for formulas involving e raised to a power, include the math header, and advance the loop with time += increment to prevent an infinite loop.
- Print time and all four battery values to two decimal places, and use a field width such as %8.2f to align table columns.
- Clamp negative linear and piecewise results to zero; the piecewise model reaches zero after 14 hours, while exponential decay approaches zero without reaching it.
- Treat very small exponential values, for example below 0.00001, as effectively zero, then test increments such as 0.5 and 1.25 hours and verify the loop does not exceed its ending time.
- Bourke says the exam covers course material through loops, not functions, and students will not need advanced calculus or integration.
- C's standard math library includes functions such as square root, natural logarithm, and trigonometric functions, but numerical methods such as Riemann sums must be implemented separately.
- The exam has one attempt; students should remember their Canvas credentials and follow Digital Learning Commons instructions for the lockdown browser and stored belongings.
Transcript excerpt
0:05 [music] your sincerity. [music] I got a loyalty to every country wishalistic [music] fantasy that boy [music] [music] [music] I [music] [music] know I can't go around [music]
0:57 [music] conservative communist apocalyptic bastard thinking put me on this earth very privileged never >> [music] >> about your day. [music] >> All right. So, today is just going to be a review for your uh exam which starts tomorrow. If you have not already signed up for a time to go to the digital learning commons to take the exam, you need to do that immediately. uh and make sure that you're going to your assigned time. Uh you will be allowed to take one sheet of notes, handwritten or typed uh as well as a calculator and scratch paper if you need it.
1:45 The exam itself is going to be 25 multiple choice questions as has already been announced. Uh they're co they're like here here's a piece of code, what does it output? Stuff like that. uh la this is the first year that we're doing full uh DLC exams uh in a long time. It used to be as of last year for example uh it was a coding exam where you actually had to write some code and submit it. Uh of course we can't do that anymore because of too many too many problems cheating with uh AI. Uh but this was the exam from last year that we'll use as a uh as a as a a review basically. Um so here's the first problem. We've actually already done part of this before as an example. Uh
2:35 but consider a point in XY in the cartisian plane. Uh the point might lie in one of the four quadrants as depicted by this. Right? Remember we already did
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Chris Bourke.