Logical || operator determines if either or both of the statements used are true. - C++ Operator

C++ examples for Operator:Logical Operator

Description

Logical || operator determines if either or both of the statements used are true.

Demo Code

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    bool isTrue { (1 == 1) || (0 == 1) };
    cout << "True? " << isTrue << endl;

    isTrue = (0 == 1) || (1 == 1);//from ww w  .ja  v  a2 s.  co m
    cout << "True? " << isTrue << endl;

    isTrue = (1 == 1) || (1 == 1);
    cout << "True? " << isTrue << endl;

    isTrue = (0 == 1) || (1 == 0);
    cout << "True? " << isTrue << endl;

    return 0;
}

Result


Related Tutorials