Expressions become statements if you add a semicolon at the end of them (K&R C book)

Last update: 05 January, 2026

Two things I found interesting and wrote down while reading the K&R C book (The C Programming Language by Ritchie & Kernighan), back in May 2024. I revisited again the note in 2026, and to be honest, I had forgot the 1st.

1. expressions vs statements

Expressions become statements if you add a semicolon at the end of them, K&R C book, Chapter 3.1, “Statements and Blocks”:

An expression such as x = 0 or i++ or printf(...) becomes a statement when it is followed by a semicolon, as in:

 x = 0;
 i++;
 printf(...);

In C, the semicolon is a statement terminator, rather than a separator as it is in languages like Pascal.

For more types of statements in C++ (we saw expression statements here), see https://en.cppreference.com/w/cpp/language/statements

2. braces

Also braces {} combine multiple statements into compound statements, which is another statement type.

Braces { and } are used to group declarations and statements together into a compound statement, or block, so that they are syntactically equivalent to a single statement. The braces that surround the statements of a function are one obvious example; braces around multiple statements after an if, else, while, or for are another. (Variables can be declared inside any block; we will talk about this in Chapter 4.) There is no semicolon after the right brace that ends a block.

Other things to read

Popular

Previous/Next