Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
2.2 Program Construction 63 The second, and more common, form begins with two slashes ( // ) and extends to the end of that line of the program: string idNumber; // Identification number of the aircraft The compiler ignores anything after the two slashes. Writing fully commented programs is good programming style. A comment should appear at the beginning of a program to explain what the program does: // // // // // This program computes the weight and balance of a Beechcraft Starship-1 airplane, given the amount of fuel, number of passengers, and weight of luggage in fore and aft storage. It assumes that there are two pilots and a standard complement of equipment, and that passengers weigh 170 pounds each. Another good place for comments is in constant and variable declarations, where the comments explain how each identifier is used. In addition, comments should introduce each major step in a long program and should explain anything that is unusual or difficult to read (for example, a lengthy formula). It is important to make your comments concise and to arrange them in the program so that they are easy to see and it is clear what they refer to. If comments are too long or crowd the statements in the program, they make the program more difficult to read--just the opposite of what you intended!