Download Dynamic C User Manual
Transcript
13.6 Logical Operators
&&
Logical AND. This is a binary operator that performs the Boolean AND of two values. If either
operand is 0, the result is 0 (FALSE). Otherwise, the result is 1 (TRUE).
||
Logical OR. This is a binary operator that performs the Boolean OR of two values. If either operand is non-zero, the result is 1 (TRUE). Otherwise, the result is 0 (FALSE).
!
Logical NOT. This is a unary operator. Observe that C does not provide a Boolean data type. In C,
logical false is equivalent to 0. Logical true is equivalent to non-zero. The NOT operator result is 1
if the operand is 0. The result is 0 otherwise.
test = get_input(...);
if( !test ){
...
}
13.7 Postfix Expressions
( )
Grouping. Expressions enclosed in parentheses are performed first. Parentheses also enclose function arguments. In the expression
a = (b + c) * 10;
the term b + c is evaluated first.
[ ]
Array subscripts or dimension. All array subscripts count from 0.
int a[12];
j = a[i];
Chapter 13: Operators
// array dimension is 12
// references the ith element
185