Skip to content

Expressions

Recall, from the introduction lesson, that a program is made up of instructions (operators, functions, methods) that manipulate variables & data structures stored in memory and some logic that determines the order of execution (control flow). These instructions can be broadly categorized into expressions and statements.

1. Expressions
An expression is a piece of code that the programming language evaluates to produce a value. Expressions are the building blocks of programs: they combine values, variables, operators, and function calls to compute results that programs use or store.
2. Statements
A statement is a complete instruction that performs an action, such as assigning values to variables or controlling the flow of execution. Statements may contain expressions, but their primary purpose is to do something rather than to produce a value.

Expressions vs. Statements

Expressions are something, statements do something.

For a deeper discussion of statements (assignment, control-flow statements, scope, and side effects), see the companion lesson: ../.. /lessons/3_control_flow/statements.md.