13-08-2012, 04:26 PM
Operators and expressions
Operators and expressions.pptx (Size: 1.13 MB / Downloads: 28)
Operators
An operator is a symbol that specifies arithmetic , logical or relational operation to be performed.
The data items that operators act upon are called operands.
An expression is any computation involving variables and operators that yields a value.
UNARY OPERATORS
operators that act upon a single operand to produce a new value are called unary operators.
Unary minus operator
Unary – operator negates the value of its operand
This operator reverses sign of the operand value
If a=5 then –a will be -5
If a=-4 then –a will be 4
-a doesnot change the value of a at the location where it permanently resides in memory
Explicit conversion
Explicit conversion is user defined that forces an expression to be of specific type
Explicit conversion of an operand to a specific type is called type casting
General form of casting is
(data type) expression
The expression is converted to the data type specified in parenthesis
The data type associated with the expression itself is not changed by a cast. Rather, it is the value of the expression that undergoes type conversion