Logical Operators In C++

Logical Operators AND , OR , NOT Operator In C++

Posted by Zohaib Qazi on may 15, 2017

Logical Operators In C++

After reading this post you will come to understand that what Logical Operators are. What is AND Operator, OR Operator and NOT Operator. However, clear your concept by reading this post and watching our Balochi videos which is placed below.

C++ language supports logical operators which are shown in tables along with definations.
1 is equal to true
0 is equal to false
Example A = 1
B = 0

AND Operator ( Sign -> && )

And operator uses more than one condition if all conditions are true than result will be true, otherwise the result is false.And table is shown below.

Condition1 Condition2 Result
1 1 1
1 0 0
0 1 0
0 0 0

Or Operator (Sign -> ||)

Or operator uses more than one condition if any one of condition is true than result will be true, otherwise the result is false. And table is shown below.

Condition1 Condition2 Result
1 1 1
1 0 1
0 1 1
0 0 0

Not Operator (Sign ->!)

Not operator is the inverse of the condition. If the condition is true then the result will be false and if the condition is false then the result will be true. And table is shown below.

Condition Result
1 0
0 1

Logical Operator C++ Video in Balochi

Logical Operator In C++ code by balochprogrammer


#include < iostream >
using namespace std;
int main()
{
int a = 10;
int b = 20;
if ( a = = "10" && b = = "20"){
cout << " And Operator condtions are true: " << endl ;
}
if ( a = = "10" || b = = "15"){
cout << " Or Operator any One of Condtion is true: " << endl ;
}
cout << " Not Operator condition true : " << ! ( a > 6) << endl ;
}
return 0 ;
}