A computer program is a list of "instructions" to be "executed" by a computer
In a programming language, these programming instructions are called statements
A statement is a syntactic unit of a programming language that expresses some action to be carried out
A statement may have internal components (e.g., expressions)
A statement directs the computer to perform a specified action
A single statement in a high-level language (like C, Java) can represent several machine-language instructions
Statements are composed of:
Values, Operators, Expressions, Keywords, and Comments
Consider following example javascript code
function ncx() {
var x;
x = "seventeen";
var y = 17 + 2;
x = y; x = x + 17 + 2 * math.sqrt(17);
return x;
}
ncx();
Here, var x;
var y = 17 + 2;
are declaration statements
x = "seventeen";
x = y;
and x = x + 17 + 2 * math.sqrt(17);
are statements which assign values (also var y = 17 + 2;
)
return x;
is a return statement which uses the keyword return
The 5th line contains two statements seperated by ;
(semi-colon)
Lines 1-7, can be termed as a function statement, which contains a body of multiple statements
ncx();
is a function-call statement