C++ - And Logical Operator(&&) - Not Logical Operator(!)

 

C++  - And Logical Operator - Not Logical Operator

And Logical Operator:

  • You use the AND operator, && when you have two conditions that must both be true for a true result. 
  • The && operator only produces a true result if both operands are true. If either or both operands are false, then the result is false

Examples:

  • 6 > 4 && 2 <= 14
  • 14 > 7 && 5 <= 5

if(age>25 && income>25000){

 cout<<"Sir,You can apply for Loan"; 

Not Logical Operator:

  • The operator accepts a single argument and does the following:
  • Converts the operand to boolean type: true/false
  • Returns the inverse value.

Examples: 

  • !(x > 5)
  • if (xyzzy != true) 
  • !(x > 3 && x < 10) 
  • ! (13 != 7) 

Post a Comment

0 Comments