Expression Statements




An expression can be used to form a statement. A semicolon without an expression is a vacuous statement. Usually, expression statements involve assignment operators or are function calls - although not always.

An ambiguity exists between certain forms of expression statements and declarations. See the section titled ambiguity resolution for a discussion of this issue.


int i=0;
int j=1;
i == j;  // expression statement that returns 0 and has no side effects.
i = j;   // an expression statement involving an assignment that has a side effect - the new value of i is returned.
i++;     // an expression statement that increments i - the previous value of i is returned.

 goto label; // jump over infinite loop
 for(;;);    // the initialization statement is vacuous - the loop goes forever
 label:;     // labelling a vacuous statement before end of the block
while(++i < 100); // vacuous expression statement after the while, loop terminates because of side effects
printf("The value of i is: %d",i);  // function call is an expression statement