top of page
Formatting
The formatting of code is extremely important and improper formatting will lead to a bad time. Code should be formatted in a way which is clearly understandable and easy to come back to and work within the future. Formatting is still quite often different between various coders, however, if that format remains clear and homogeneous throughout the entire code, others can pick up on it.
Homogeneous Programming
The most important formatting factor while programming is the homogeneity factor. All the code should closely imitate the style used all throughout the entire program. You wouldn't write an essay in two different languages because it makes it confusing and impossible to read for some. The same applies to programming concepts. Everyone has their own unique way of thinking and programming style so don't worry over trying to be perfect and embrace your unique style. By keeping the formatting the same all throughout the code, no matter how different your programming style is to others, it can be understood and picked up on easily.
Readability
Code should be easy to read and not take a rocket scientist to piece the code apart. If a line of code is so long that it extends across multiple monitors... something is wrong. If the code is so squished together that it is not understandable... something is wrong. In C since statements are semicolon separated/terminated (they terminate by the inclusion of a ; character) it is possible to squishify code however this causes catastrophic mayhem when trying to work with the code in the future or working with team members.

This is an example of poorly formatted code. Although this code will execute just fine, it is squished together to the point of making reading it confusing.
Separation
The separation and spacing of various lines and functions/statements can clearly identify where a reader should look for specific blocks of code. There should always be at least one empty line between the #include statements and the function initializers. It is also common practice to separate variable declaration to the top of the program with a space before code execution.

Indentation is the spacing of the line of code from the leftmost wall. Spacing the code at varying lengths helps the reader understand which part of the code belongs inside and outside varying code blocks.
The statements inside of a function are indented (usually by one-tab length but as long as the length remains the same throughout any length may be used)
Commenting & Professionalism
Commenting throughout your code is an important concept which may be hard to grasp at first but when the time comes to make a big program it really pays off. Leaving notes behind can improve efficiency when looking back at the code. It is generally recommended to leave comments before every function that explains what the function does. Comments should also be used to explain any code which is complex and may confuse you if you were to leave it and come back after a while. This may include complicated single statements, loops, functions, classes.... everything.

To follow professional standards, a heading is recommended to be put at the top of the project that describes: The author, the filename and other included files, the date last modified, and a brief summary of the program.
These headings can be styled however you would like as long as it helps the reader and gives the author accreditation.
While working with larger programs, headings and comments make all the difference in work-ability and readability.
bottom of page