Lecture
Indentation — a way of formatting program code using indents so that structural blocks are clearly visible. Why indentation is needed:
In addition, there are certain programming languages (Python and several languages derived from it) where indentation is mandatory and directly affects program execution. In most programming languages indentation is not mandatory, however it is strongly recommended by all guides on writing program code.
Indentation style — the rules for formatting source code, according to which the indents of program blocks are placed in a readable manner.
The indentation style being used is usually specified separately in the code formatting standard.
The text editors included in most popular development environments often provide tools to support the indentation style being used, for example, automatic insertion of spaces/tabs when typing the braces that mark the beginning/end of a logical block.

There are four main indentation styles in C. Described below, they all aim to make it easier to visually track control structures. The point of contention is the placement of the braces { and } and the arrangement of statements (if, else, for, while, or do) into blocks.
Named after Kernighan and Ritchie because all the examples from their book «The C Programming Language» (often referred to simply as «K&R» by the authors' initials) are formatted in this way. Also known as «kernel style» (BSD KNF; because the UNIX kernel is written in it), and also as the «One True Brace Style» (1TBS) according to its adherents. The main indent, shown below, consists of 8 spaces (or one tab) per level. Although 4 spaces are most often used.
Allman style — named after Eric Allman, a programmer from the University of Berkeley, who wrote many BSD utilities in it (also known as «BSD style»). It has similarities with Pascal and Algol. This style is offered by default in Microsoft Visual Studio.
The style is as follows:
An example of code formatted in Allman style:
Whitesmiths style — popular because of the examples that came with Whitesmiths C — one of the first compilers of the C language. The main indent per level for braces and the block — 4 spaces.
GNU style — used in all sources of the GNU project (for example, GNU Emacs). The indent is 2 characters per level, and the braces are placed at their own indent .
Comments