WEB DEVELOPER SITE
PYTHONPHPJAVA
 

C++ Operators


c++ operator are very helpful we learn basic operator such and, not, or


The file may be opened in one of the following modes:

Opertor Name of Operator Form
&& AND Operator x&&x
! Not Operator
|| OR Operator x||y

AND OPERATOR

In the AND operator, both operands must be true for the entire expression to be true.

Exmple

the logical AND operator was used to combine both expressions. we can say if statement evaluates to true only if both expressions are true.
int main()
{
    int age = 36;
    if (age > 25 && age < 50) {
        cout << "Accepted!" << endl;
    }

    return 0;
}
//Accepted



OR Operator

The OR (||) operator returns true if any one of its operands is true.

Example

int main()
{
    int age = 6;
    int score = 70;
    if (age > 8 || score > 24) {
        cout << "Accepted!" << endl;
    }

    return 0;
}

multiple OR and AND statements may be chained together.

Logical NOT

The logical NOT (!) operator works with just a single operand, reversing its logical state. Thus, if a condition is true, the NOT operator makes it false, and vice versa.
int main()
{
    int age = 10;
    if ( !(age > 12) ) {
        cout << "Your age is less than 12" << endl;
    }

    return 0;
}
//output
Your age is less than 12





Welookups is optimized for learning.Copy right 2018 kumar aditya singh .
All Right Reserved and you agree to have read and accepted our term and condition.
All Rights Reserved.

welookups.com