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 main wraps 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

  1. Lesson 1, learn (10 to 15 minutes): Review the symbols from earlier weeks. Watch the main skeleton on the keyboard demo and type it three times.
  2. Lesson 2, practice (10 to 15 minutes): Write a short program that uses printf("hello") and return 0. Check that the parentheses close on every line.
  3. 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.

  1. Lesson 1: Learn

    Keywords

    12 minutes

    Start
  2. Lesson 2: Practice

    Practice

    12 minutes

    Start
  3. Lesson 3: Review and test

    Review and test

    12 minutes

    Start

All weeks