HP 3000 Manuals

Expression and Null Statements [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

Expression and Null Statements 

An expression in C can also be a statement.  A null statement is an
expression statement with no expression and it is used to provide a null
operation.

Syntax 

     expression-statement ::=
          [expression]; 

Description 

You can use any valid expression as an expression statement by
terminating it with a semicolon.  Expression statements are evaluated for
their side effects such as assignment or function calls.  If the
expression is not specified, but the semicolon is still provided, the
statement is treated as a null statement.

Null statements are useful for specifying no-operation statements.
No-operation statements are often used in looping constructs where all of
the "work" of the statement is done without an additional statement.  For
example, a program fragment that sums up the contents of an array named x
containing 10 integers might look like this:

       for(i=0,s=0; i<10; s+=x[i++]);

No additional statement is necessary to specify the required function,
however, the syntax of the for statement requires a statement following
the closing ) of the for.  To meet this syntax requirement, you can use a
null statement.

Example 

     expression;:
     x=y;



MPE/iX 5.0 Documentation