Week 14: Small programs I
C code typing course. 23 wpm, 94% accuracy.
This week you do not learn a new symbol. Your goal is to bring together the symbols you practiced in the first thirteen weeks inside one small program. A small C program usually lives inside a function called main. It starts with a call that prints a line of text, and it ends with return. Every line this week should feel familiar, because each one uses a structure you have already practiced.
What you will learn
There are no new symbols. You will use these structures when you write programs:
int main(void): the function where the program starts.printf("hello"): prints text to the screen.return 0: tells the system that the program finished successfully.
A short program skeleton looks like this: the int main(void) line opens the function, printf("hello") is called inside it, and return 0 closes the function.
Technique tips
- Plan the closing brace as soon as you open a block. The brace of
mainwraps every line of the program. - Press Enter and the indentation comes automatically. Do not add spaces at the start of lines by hand.
- Write short lines rather than one long line. After each line, look at the screen and confirm it is correct before going on.
- When you get an error, check the parentheses and quotes first. Checking those two groups is a quick way to find many of these mistakes.
Lessons
- Lesson 1, learn (10 to 15 minutes): Review the symbols from earlier weeks. Watch the
mainskeleton on the keyboard demo and type it three times. - Lesson 2, practice (10 to 15 minutes): Write a short program that uses
printf("hello")andreturn 0. Check that the parentheses close on every line. - Lesson 3, review (10 to 15 minutes): Take the two-minute test and type the first lines of the program. Save your result and practice the line that gave you trouble.
This week’s goal
This week’s target is 23 WPM and 94% accuracy. Finishing the week’s lessons earns you 1 star. Reach 94% accuracy for 2 stars, and also reach 23 WPM for 3 stars. Every line of a program matters, so focus on accuracy first and let speed follow.
This week’s lessons
Do the lessons in order. Each one ends with a test, and your best result is saved.