User Tools

Site Tools


guides:programstyle:codeblocks

This is an old revision of the document!


Compound Statements or Code Blocks

In c/c++ statements can be grouped into a single statement using a code block or “curly braces”. The most common use of a code block is to extend the content of the body of a control structure to include more than one statement.

The syntax for an if statement is

   if (boolean expression) statement;

Using a code block this is extended to

   if (boolean expression) {
       statement1;
       statement2;
       ...
       statementn;
   }
guides/programstyle/codeblocks.1595600586.txt.gz · Last modified: 2024/07/25 15:01 (external edit)