Book
Collection
Click for Table of Contents
© 2025 by Rance D. Necaise
C Primer for Python Programmers
Copyright © 2025
Rance D. Necaise

2.3 Free-Form Statements

Languages specify the requirements for constructing statements as part of the syntax. Some languages have strict requirements in the construction of an individual statement. Python, for example, requires that a single statement be specified on a single line unless a backslash is used at the end of the line to indicate it continues to the next line. In addition, Python requires statements within a statement block to be indented with all statements within the block indented to the same position.

Statements

The statements in C can be specified in free-form. That is, they can be spread across multiple lines and the indentation of a statement has no meaning. For example, the hello world program could be rewritten as shown below and it would still compile.

  1. /* hello.cc
  2.    The hello world program in C.
  3.  */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main(
  8. ){ printf("Hello World!\n"); }
Note
Note

Although statements can be written across multiple lines as shown in the example above, it can be difficult to read programs written in this fashion. Thus, you should not do this as it is considered a poor programming practice.

Languages that are free-form must use a specific symbol to indicate the end of the statement. Thus, statements in C must end with a semicolon (;).

Statement Blocks

When a block of statements is required, you must enclose the statements within a pair of curly braces @ and @. A semicolon is not included after the braces, but the statements within the block do require a semicolon just like any other statement. Consider the statements within the body of the main function

  1. int main()
  2. {
  3.   printf("Hello World!\n");
  4. }

Although C does not require statements to be indented within a statement block, good programming style suggest that you should indent the statements to the same level. This improves the readability of your source code.