Adapted from:

Acceptable form for programs in CMP 156
Fall, 1998
George Ball


Your program will start with a comment block. The comment block will contain:

  1. The name of the file that contains the program
  2. The title of the program, and a few lines of explanation (if needed)
  3. The author of the program
  4. The class the program was written for (i.e. APCS)
  5. The date the program is due. Note: The year number should be 4 digits. Acceptable forms are: September 15, 1998; 09-15-1998; 17 September, 1998; 9/15/1998.
  6. The version number of the program, starting with 1.0

In each comment line, the // symbol will be followed by a blank space, and the first word will start with an uppercase letter.

The comment block will be followed by a blank line. The #include lines will follow (there will always be at least one.)

The #include lines will be followed by a blank line. The main( ) function will have its beginning and ending { } lined up in the left margin, and they will be alone on their lines. The body of the main function will be indented at least 3 spaces from the left margin.

Any operator symbol (such as <<, >>, <, >, +, -, *, /, =, etc) will be preceded and followed by a blank space to separate it from the rest of the expression.

Each main( ) will terminate with a return 0; line, which will be preceded by a blank line. Comment sparingly in the code. Make sure your comment words and any output words are spelled correctly.

Example

// File first.cpp
// A first program in C++
// Written by George W. Ball
// Written for APCS
// Due: September 9, 1998
// Version 1.1

#include <iostream.h>

main()
{
   cout << "Welcome to APCS and to C++!\n";
   cout << "Please follow this example for programs." << endl;

   return 0;
}


Last updated September 5, 1998