Thursday, August 4, 2011

Conditions and Conditional Operators

Numerical Comparison Operators






















































































































































OperatorSyntax Description
<a < bResult is true if a is less than b; otherwise, it is false.
<=a <= bResult is true if a is less than or equal to b; otherwise, it is false.
>a>bResult is true if a is greater than b; otherwise, it is false.
>=a>=bResult is true if a is greater than or equal to b; otherwise, it is false.

Boolean Logical Operators








































































































































































































































































































































































































































































































































































































































































































































































OperatorDescriptionExamplesResult
&&Conditional -ANDfalse && falsefalse
false && truefalse
true && falsefalse
true && truetrue
Conditional -ORfalse falsefalse
false truetrue
true falsetrue
true truetrue
&Logical-ANDfalse & falsefalse
false & truefalse
true & falsefalse
true & truetrue
Logical-ORfalse falsefalse
false truetrue
true falsetrue
true truetrue
^Logical -XORfalse^falsefalse
false^truetrue
true^falsetrue
true^truefalse



Compound Assignment Operators:









































































































Operator





Description





Example





Same Result as





+=





Increment assignment operator





x += 5;





x = x + 5;





–=





Decrement assignment operator





x –= 5;





x = x – 5;





*=





Multiplication assignment operator





x *= 5;





x = x * 5;





/=





Division assignment operator





x /= 5;





x = x / 5;





%=





Modulus assignment operator





x %= 5;





x = x % 5;


No comments:

Post a Comment