Week 10: Functions
C code typing course. 19 wpm, 93% accuracy.
A function is a piece of code that you give a name and call whenever you need it. In C, a function definition has a return type, a name, a list of parameters and a body. The parameters sit inside parentheses and are separated by commas. This week you practice typing (, ) and , on the US English layout, and you write a small function from start to finish.
What you will learn
On the US English layout:
(: the 9 key with Shift. Press Shift with the opposite pinky, and press 9 with your right ring finger.): the 0 key with Shift. Press Shift with the opposite pinky, and press 0 with your right pinky.,: the , key, with your right middle finger.
A function that adds two numbers:
int add(int a, int b) {
return a + b;
}
Technique tips
- Do not try to type the whole function in one rush. Finish the line
int add(first, then add the parameters, and write the body last. - Put a space after each comma in the parameter list. The space makes it easy to see where one parameter ends.
- After you press the comma key with your right middle finger, return that finger to the home row.
- Check the screen. Count the opening and closing parentheses on the first line before you go on.
Lessons
- Lesson 1, learn (10 to 15 minutes): Watch the
(,)and,keys on the keyboard demo. Type each symbol five times. - Lesson 2, practice (10 to 15 minutes): Type the line
int add(int a, int b)and the body from the example. Check each comma in the parameter list. - Lesson 3, review (10 to 15 minutes): Take the two-minute test with function lines. Save your result and practice the lines where you slowed down.
This week’s goal
This week’s target is 19 WPM and 93% accuracy. Finishing the week’s lessons earns you 1 star. Reach 93% accuracy for 2 stars, and also reach 19 WPM for 3 stars. One missing parenthesis in the first line causes errors in the lines below it, so keep accuracy 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.