/ˈsteɪt.mənt/
noun — "a single instruction your code politely issues to the computer."
Statement is a fundamental unit of programming that expresses an action to be performed by the computer. Statements are the building blocks of code, defining operations like assignments, loops, conditionals, function calls, and declarations. Properly structured statements follow the syntax rules of the language to execute correctly.
Technically, Statement involves:
- Expression statements — performing computations or calling functions.
- Control statements — guiding the flow of execution, such as loops and conditionals.
- Declaration statements — defining variables, constants, or functions.
- Compound statements — grouping multiple statements, often enclosed in braces or blocks.
Examples of Statement include:
- Assignment:
int x = 5; - Conditional:
if (x > 0) { doSomething(); } - Loop:
for (int i = 0; i < 10; i++) { sum += i; }
Conceptually, Statement is a command in your program’s vocabulary—it tells the computer exactly what to do step by step. A program is essentially a carefully ordered collection of statements.
In practice, understanding statements and their proper syntax is essential for writing reliable, maintainable, and bug-free code. Statements interact with runtime systems, functions, and exceptions during execution.
See Syntax, Loop, Conditional, Function, Runtime.