Statements & Expressions

A Statement is a line of code that does something / a unit of execution (e.g. a for loop), and is terminated with a semi-colon;

 

An Expression is a unit of computation, which evaluates something to a value (e.g. x = 1 + 2). Thus an expression has a value (which might be void in some cases).

 

Some statements are also expressions, and vice-versa!

 

Most statements are expressions, but what makes an expression a statement is the fact that it is terminated by a semi-colon;

 

Compound Statements are enclosed within {curly braces} on multiple lines; aka a statement block or a code block.

Leave a Reply