Project Home

C++ Tutorial: Section 1

spoon lifting 
cereal in milk out of a green bowl
Photo by Binyamin Mellish from Pexels

In this tutorial, we'll cover the basics of C++ programming so that you'll have all the information you need to complete the project. It's designed for the complete programming novice, so if you're an experienced programmer, skim the following and then feel free to jump right into the example programs!

C++ is a programming language that you can use to control your computer. A programming language is just like a regular language---it has a vocabulary and a set of rules for how to make commands. A program is nothing more than a list of commands, or instructions, that you give to the computer. When we write a program, we first begin by thinking very carefully about what we want the computer to do, and create a step-by-step plan for how the computer will do it. This step-by-step plan is called an algorithm. For example, an algorithm for making a bowl of cereal might look like the following:

  1. Take out a bowl from the cabinet and place it on the counter
  2. Take out a box of cereal from the cabinet and open it
  3. Pour the cereal from the box into the bowl until it almost reaches the top of the bowl
  4. Close the box and put it back in the cabinet
  5. Open the fridge and take out the milk
  6. Open the milk and pour it into the bowl until the cereal reaches the top of the bowl
  7. Close the milk and put it back in the fridge
  8. Take a spoon from the silverware drawer and put it in the bowl

Notice how detailed that algorithm is! When you write an algorithm, you want to be as detailed and specific as possible, because computers are really stupid. They only know as much as you tell them, so if you want to the computer to do something correctly, you'd better tell it exactly how and give it enough information to complete the task.

We'll come back to the idea of an algorithm in just a moment, but first let's write our first C++ program.