CSCI 150
Home | | Course Schedule | | Assignments | | Lecture Notes
Program Prologues:
Comments are notes that the programmer writes in English, stating what
a particular piece of code does, who wrote it, etc. They are not part
of the program that the computer will execute. In Pascal, comments are
set apart from the regular code using brackets: {}. Every program you
write in this class will have a program prologue that contains the name
of the program, your name, the date, the class and section, the assignment
or lab number and the purpose of the program. The standard prologue
should look as follows:
{program: FairyTale.pas Author: Brenda Student Class: CSCI 150, Section 01 Date: 2/19/01 Assignment: Lab 3 Purpose: Create an interesting and unique fairy tale}
Comments on variables:
Each variable declaration should have a comment next to it
indicating the purpose of the variable.
{program: Scoobydoo.pas Author: Brenda Student Class: CSCI 150, Section 01 Date: 9/6/01 Assignment: Homework 2 Purpose: Solves Mysteries} program Scoobydoo; var monster: string; {Name of monster in mystery} snacks: integer; {number of scooby snacks available} begin {Code for main program is here} end. {end Scoobydoo program}
Comments at the beginning and end of major program blocks:
Each
procedure or function should have a prologue giving the name purpose and
a description of the parameters used in the function or procedure call.
Each major function, procedure or program block
should have a comment immediately following the end statement indicating
the name of the function or program that is just ended.
An example follows:
{program: Hephalump.pas Author: Brenda Student Class: CSCI 150, Section 01 Date: 3/22/01 Assignment: Homework 5 Purpose: Hunts for and talks to hephalumps} program hephalump; procedure hunt( num1 : integer; name : string); {procedure: hunt purpose: Find hephalumps and greet them. parameters: num1 is an integer indicating the number of hephalumps name is a string indicating the name of the user} var answer: string; {What the hephalump says} begin {Code for hunt procedure is here} end; {end hunt procedure} var remark: string; {What you will say to a hephalump} number: integer; {number of hephalumps} begin {Code for main program is here} end. {end hephalump program}