Thursday, March 25, 2010

Operators - This operation is not painful

Operators – An operator is a symbol or letter, which makes the computer perform specific operation in a programming statement.

Assignment Operator =Assigns a value to a variable or property.
variable = value
variable : Any variable or any writable property.
value : Any numeric or string literal, constant, or expression.

Remarks
The name on the left side of the equal sign can be a simple scalar variableor an element of an array. Properties on the left side of the equal sign can only be those properties that are
writable at run time.

Arithmetic Operator - Operators that perform numeric calculations known as arithmetic operators are: + (addition), – (subtraction), * (multiplication), / (division) and % (modulus).

Relational Operator - An operator that manipulates numeric and other values to produce a logical result. The relational operators are <, <=, >, >=, = = and !=.

Unary Operator - The unary assignment operators, use two operand instead of one, for the increment (++) and decrement (– –) operators. Its also call
increment/decrement operator. a++, a--, a+=10.

Unary-Operator : one of & * + – ~ !

Ternary Operator – Can be used to replace certain of if – else-if statement. Its require three operands to work on. It represent by the ? and : symbols. Expression1?Expression2:Expression3. e.g. tax = salary>10000?salary*0.05 : 0; (if variable salary stored more than 10000 then tax variable will calculated 5% of salary otherwise tax will be).

Logical Operator - An operator that produces a logical result (true or false); sometimes called a Boolean operator. The logical operators are used for expression grouping, NOT or ! (negation), AND (Creates a Boolean behavior that represents the logical AND of the given behaviors. The behavior's value is true when both b1 and b2 are true; otherwise, it is false. OR (Creates a Boolean behavior that represents the logical OR of the given behaviors. The behavior's value is true when either b1 or b2 are true; otherwise it isfalse).

Binary Operator – This operator do the binary operations between two or more variables. Also known as bits operator. The bitwise operators perform bitwise-AND (&), bitwise-exclusive-OR (^), and bitwise-inclusive-OR (|) operations. E.g. 101 & 100 = 100 (Multiplication). 101 ! 100 = 101 (Addition). 101 ^100 = 001(If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0). Right shift  >>; Left shift << (The value of a right-shift expression e1 >> e2 is e1 / 2e2, and the value of a left-shift expression e1 << e2 is e1 * 2e2).

One thing I can assure you that these operators will never ditch you. So, use these and if want anything can leave a comment or mail me back.

!!!Once more time has come to say you  Tofa, see you next week.!!!

No comments: