Expression Statements

When an expression statement is executed, the expression is evaluated according to the rules outlined in Expressions and Assignments.

The expression evaluation has to be completed before the next statement is executed.

Syntax

expression-statement:  expression;

Example

These examples demonstrate expression statements:

int a = 0;
a++;
a = 5 + a;
int res = add(4, 6) + 1;

In the last statement, the value returned by the add function is increased by 1 and then assigned to the res variable.

Last updated