User Tools

Site Tools


guides:programstyle:indentation

This is an old revision of the document!


Indentation

The goal of indentation is to make it easier for programmers to recognize blocks of code contained within a structure. To that end, code within a structure should be indented by a standard amount. A second use of indentation is to associate code from a single statement which exceeds a single line with the beginning of that statement.

Code in a Code Block

int value;
 
int max, 
    min;
 
int count = 0;
 
cin >> value;
max = value;
min = value;
 
while (cin) {
   if (max < value) {
      max = value;
   }
 
   if (min > value) {
      min = value;
   }
 
   count++;
   cin >> value;
}

A single statement occupying multiple lines

guides/programstyle/indentation.1595593479.txt.gz · Last modified: 2024/07/25 15:01 (external edit)