Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
Basic Structure

C++ Program Structure

There are two basic parts to a C++ program:

  1. Instructions to the C++ preprocessor and compiler.
  2. Instructions that describe the processing to be done.

However, before we can describe these instructions, we must have a way of naming things so that we can tell the compiler about them and describe what we want to have done to them. We name things (data types, data objects, and actions) by giving them an identifier. An identifier is made up of letters, numbers, and underscores, but must begin with a letter or an underscore. We use the words identifier and name interchangeably.

Beware: C++ is case sensitive. That means that Value, VALUE, value, and vaLue could be four different identifiers.

C++ Program Structure

Let's examine the following C++ program. We have numbered the lines so that we can discuss them easily.

Semicolons terminate statements in the C++ program. There are 6 semicolons in the preceding program, so there are 6 statements in the program.