Friday 21 October 2016

Conditional Operators

Conditional operators

  • Conditional Operators are,
      • &&   Logical AND
      • ||    Logical OR
      • !      Logical NOT
      • ?:    Ternary (shorthand for if-then-else statement)
Operator
Meaning
&&
conditional -AND operator
||
conditional-OR operator
? :
ternary operator in form of: A ? B : C
  • && and || are used on two boolean expressions and gives the result as boolean type.
  • && operator : if the left expression is evaluated to false, then the right expression is not evaluated. Final result is false.
  • || operator: if the left expression is evaluated to true, then the right expression is not evaluated. Final result is true.
     Thanks for your time.
     Nireekshan