There is a sentence about "statement" that I can't understand in C Primer Plus by Stephen Prata.
In Chapter 5, there is a section which explains difference between statement and expression. The author explains statement as follows:
Statements
Statements are the primary building blocks of a program. A program is a series of statements with some necessary punctuation. A statement is a complete instruction to the computer. In C, statements are indicated by a semicolon at the end. Therefore,
legs = 4
is just an expression (which could be part of a larger expression), butlegs = 4;
is a statement.
And then the author gives an example:
Although a statement (or, at least, a sensible statement) is a complete instruction, not all complete instructions are statements. Consider the following statement:
x = 6 + (y = 5);
In it, the subexpression
y = 5
is a complete instruction, but it is only part of the statement. Because a complete instruction is not necessarily a statement, a semicolon is needed to identify instructions that truly are statements.
The authors says that "y=5"is a complete instruction but as she mentioned above isn't this just an expression, not a complete statement?