Before coming to Class 1, please complete the following tasks:
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Lecture | Week 2 | Watch this week's first lecture. You can skip from 9:00 to the 19:30 minute mark (David makes Harvard-specific announcements, and talks about their academic honesty guidelines). |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Short | Typecasting | Watch this short, which focuses on data types and typecasting. |
| Follow-Along | Walkthrough | floats-0 | Following David, write a program that prints out a float. Start writing the program first by grabbing the code from the Helpful Resources here. |
| Follow-Along | Walkthrough | floats-1 | Keep following David to solve the problem from the previous video. You can get instructions to start the program here. |
| Follow-Along | Walkthrough | floats-2 | Continue the follow-along with David as he "blows your mind" with floating-points! You can get instructions to start the program here. |
| Read | Resource | Typecasting | Read over this resource that should help reinforce your knowledge of numeric types, and how/when to cast between them. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Resource | Chars | We've seen int, float, string. Now learn about a new data-type, the char. |
| Read | Lecture Notes | Week 2 / Typecasting | Read the notes for the "Typecasting" section. This will explain typecasting using a program that converts alphabetical letters to their ASCII equivalents. Stop at the References header. |
| Follow-Along | Walkthrough | ascii-0 | Follow David to write the same ASCII program you just read through in the Lecture Notes. Start writing the program first by grabbing the code from the Helpful Resources here. |
| Follow-Along | Walkthrough | ascii-1 | Continue following David. Pay attention to when David talks about equivalence between chars and ints. You can get instructions to start the program here. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Resource | Calling Functions | Read over this resource to review how to call a library function, and understanding a return value vs a side effect. |
| Do | Exercise | Small Talk | Write a program that makes small-talk with the user, responding differently for lengths of inputs |
| Read | Resource | Creating Functions | This resource explains how, in addition to using other people's functions like printf and strlen, we can also write and use our own functions. |
| Read | Lecture Notes | Functions and Arguments | Read the "Functions and Arguments" section of the notes, which reviews how to define your own function. Stop at the Problem Set 1 header (don't be confused: these notes are from the previous week, but we find them helpful to include here). |
| Watch | Doug's Playlist | Functions | Watch Doug's video where he breaks down functions. Feel free to practice with the problems he gives you. You can also check out the Functions section of the C Language cheat sheet here when you've finished the video. |
| Follow-Along | Walkthrough | functions-0 | Follow David to write a program in which you create your own function. Start writing the program first by grabbing the code from the Helpful Resources here. |
| Follow-Along | Walkthrough | functions-1 | Now you'll implement a function that returns a return value. You can get instructions to start the program here. |
| Read | Resource | Step Into | This video introduces you to the step into feature of the debugger, using the functions-1 example. |
| Do | Exercise | Census | Get some practice calling a function to make a repetitive program more concise and eloquent. We give you some code and ask you to refactor it by replacing a repetitive code block with a call to a function. |
| Watch | Shorts | Return Values | You might find this video somewhat confusing, especially at the end where he does an example interacting with a file, which you haven't seen before. But you might also find it somewhat helpful, so we kept it in. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Lecture Notes | Week 2 / Functions | Read over the notes from the "Functions" section. Although the focus is on creating functions, pay specific attention to the parts that talk about declaring functions, and scope. Stop when you get to the Representing Strings header. |
| Watch | Doug's Playlist | Variables and Scope | Doug discusses the importance of variables and scope, and how those relate to functions. |
| Watch | Shorts | Scope | This short will provide some examples that highlight the importance of scope. Also, David mentions "stack frames" and memory towards the end - don't worry about that for now. |
| Read | Resource | Variable Scope | Here we look at a progam with a bug related to a looping variable and its scope. |
| Do | Exercise | How Maneee | Here we give you a buggy program that uses scope incorrectly. Try to fix it! |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Lecture Notes | Week 2 / Representing Strings | Read the notes about "Representing Strings". This should be useful for the studio you'll do in Class 1. |
| Follow-Along | Walkthrough | string-0 | Now follow-along as David Malan implements the string program you read through in the notes. Start writing the program first by grabbing the code from the Helpful Resources here. |
| Follow-Along | Walkthrough | string-1 | Keep going, as David talks about the instance where GetString returns NULL. You can get instructions to start the program here. |
| Follow-Along | Walkthrough | string-2 | We can make this program even better by improving its efficiency. Follow David as he shows you how to do that. You can get instructions to start the program here. |
| Read | Resource | More on For-Loops | A brief digression to clear up any confusion about that fancy for-loop: c for (int i = 0, n = strlen(s); i < n; i++) and introduce other ways to make fancy for-loops |
| Do | Exercise | String with Indexes | Practice what you've learned about strings and indexes by writing a program that prints each character in a string along with its index. |
| Follow-Along | Walkthrough | capitalize-0 | Follow David to create a program that capitalizes a string given by the user. Start writing the program first by grabbing the code from the Helpful Resources here. |
| Follow-Along | Walkthrough | capitalize-1 | Continue following along as David introduces you to the islower and toupper functions. You can get instructions to start the program here. |
| Follow-Along | Walkthrough | capitalize-2 | Follow as David goes through the "man page" for the toupper function in order to further refine this program. You can get instructions to start the program here. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Resource | Modulo | Learn about the modulo operator by looking at a simple example program. |
| Watch | Doug's Playlist | Operators | Revisit Doug's video about Operators, or just watch the part about modulo if you prefer. |
| Do | Exercise | Clock Sage | Practice using the modulo operator to write a program that asks for an amount of time in hours, and then calculates what time it will be that many hours in the future. |