Week 6: Brackets and braces
C code typing course. 15 wpm, 91% accuracy.
Square brackets [ ] select one item from an array. Curly braces { } open and close a block of code. Both come in pairs, and each pair must close in the right place, so keep them from getting mixed up. This week you learn to type [, ], { and } on the US English layout.
What you will learn
On the US English layout:
[: the [ key, with your right pinky.]: the ] key, with your right pinky.{: the [ key with Shift. Press Shift with the opposite pinky, and press [ with your right pinky.}: the ] key with Shift. Press Shift with the opposite pinky, and press ] with your right pinky.
A quick example: numbers[0] reads the first item of an array, because C counts from zero. The three lines below form an if block:
if (x > 0) {
printf("positive");
}
Technique tips
- Think of each pair together. When you type
{, keep the closing}in mind so the block has a clear end. - Press Enter and the next line is indented for you automatically. Do not add extra spaces by hand.
- Your right pinky does most of the work here, so keep the rest of your fingers on the home row.
- Remember that counting starts at zero. In
numbers[0], the 0 points to the first item.
Lessons
- Lesson 1, learn (10 to 15 minutes): Watch the four symbols on the keyboard demo. Type each one five times, and notice how Shift changes the { and } keys.
- Lesson 2, practice (10 to 15 minutes): Type
numbers[0],numbers[1]and theifblock above. Check that every opening bracket and brace has a matching close. - Lesson 3, review (10 to 15 minutes): Take the two-minute test with bracket and brace lines. Save your result and practice the symbols you missed.
This week’s goal
This week’s target is 15 WPM and 91% accuracy. Finishing the week’s lessons earns you 1 star. Reach 91% accuracy for 2 stars, and also reach 15 WPM for 3 stars. An unclosed brace can stop a whole program from running, so accuracy comes first.
Symbols this week
The colored keys are the ones you learn this week. The color shows which finger presses the key.
This week’s lessons
Do the lessons in order. Each one ends with a test, and your best result is saved.