program-style - C Programming Style Guide 1....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
C Programming Style Guide 1. Modularization. Separate your program into independent, self-complete modules. We will talk more about this later in the semester. 2. Consistency Make your style as consistent as possible. The more consistent your style is, the easier it is to read and understand. Moreover, the less likely mistakes will be made. The more consistent your style is, the more automatic it will become. As a result, you’ll spend less time thinking about program style and more about the problem at hand. 3. Make the indenting of your code reflect the structure of the program. For example, if (count == 0) printf(‘‘No data.\n’’); fails to match the structure of the program. To do this it’s better to write if (count == 0) printf(‘‘No data.\n’’); Here’s another example. Does the indentation of the code fragment below reflect its structure? if (count != 0) printf(‘‘%d\n’’, count); average = total/count; 4. Make the reading of the program flow vertically. This is the natural flow of reading. Things that get in the way of or detract from this tend
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 06/12/2011.

Page1 / 5

program-style - C Programming Style Guide 1....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online