An expression represents a single data item, such as a number or a character. The expression may consist of a single entity, such as a constant, a variable, an array element or a reference to a function. It may consist of some combination of such entities, interconnected by one or more operators.
Expressions can also represent logical conditions that are either true or false.
Several simple expressions are shown below
a+b
x=y
x= =y
++i
The first expression involves use of addition operator (+). This expression represents the sum of the values assigned to the variables a and b.
The second expression involves the assignment operator (=). In this case, the expression causes the value represented by y to be assigned to x.
The third expression is a test for equality. Thus the expression will have the value 1 (true) if the value of x is equal to y. Otherwise the expression will have the value 0 (false).
The last expression causes the value of the variable I to be increased by 1 (i.e. incremented). Thus the expression is equivalent to
i=i+1
The operator ++ is called a unary operator because it has only one operand i.e. i
Sunday, December 6, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment