Line by Line

When you write code, you're writing a sequence of instructions that the computer follows line by line. Think of it like a recipe. If you write a simple computer program with 3 lines (like the one in this exercise), these are the steps the computer would follow to execute the program:

  • The computer reads the first line of code and runs it.
  • Once that's done, it moves on to the second line and runs it.
  • Finally, it reads the third line of code and runs it.

This step-by-step process continues until the computer has executed all the lines of code.

Code Comments

You will notice an interesting thing in the code sample: a comment. Any line of code that begins with // is ignored by the computer, as if the line was never written. Programmers write comments in code all the time to leave notes for their fellow programmers or their future selves, and I will use comments throughout these lessons to leave notes for you.

Run the code in this exercise, and see how each line is executed one after the other.

Output (Console)