C Coding Standards

Naming Conventions

Use meaningful variable names !
For example, if your program needs a variable to represent the radius of a circle, call it 'radius', NOT 'r' and NOT 'rad'.

The use of single letter variables is forbidden, except as simple 'for' loop indices.
The use of obvious, common, meaningful abbreviations is permitted. For example, 'number' can be abbreviated as 'num' as in 'numStudents'.

Use of Whitespace

The prudent use of whitespace (blank lines as well as space) goes a long way to making your program readable.

Use of Braces

Always use braces to mark the beginning and end of a loop or "if" structure, even when not required.

 

Comments

Comments are the programmers main source of documentation. Comments for files, functions and code are described below.

File Header Comments

EVERY source file (.c and .h files) should contain an opening comment describing the contents of the file and other pertinent information. This "file header comment" MUST include the following information.
  1. The file name
  2. Your name
  3. The date the file was created
  4. Your section number

 

Function Header Comments

EACH FUNCTION must have a header comment includes the following:
  1. function name
  2. a description of what the function does
  3. a description of the function's inputs
  4. a description of the function's outputs