Logical Operators Examples in C++


Logical Operators are used to combine two or more conditions/constraints or to complement the evaluation of the original condition in consideration. The result of the operation of a logical operator is a boolean value either true or false. For example, the logical AND represented as ‘&&’ operator in C or C++ returns true when both the conditions under consideration are satisfied. Otherwise it returns false. Therfore, a && b returns true when both a and b are true (i.e. non-zero).

Example Program:

Here is the simple program logical operators examples in C++.

Source Code

#include <iostream>
using namespace std;
int main()
    int a=10,b=40,c;
    if(a && b)
        cout<<"1st - Condition is true"<<endl ;

        cout<<"\n2nd - Condition is true"<<endl ;
        cout <<"\n3rd - Condition is true"<<endl ;
        cout <<"\n3rd - Condition is not true"<< endl ;
        cout <<"\n5th - Condition is true"<< endl ;
    return 0;
To download raw file Click Here


1st - Condition is true

2nd - Condition is true

3rd - Condition is not true

5th - Condition is true

Basic Programs

Flow Control

IF Statement Examples

Switch Case

Goto Statement

Break and Continue

While Loop

Do While Loop

For Loop

Friend Function in C++

String Examples

Array Examples

Structure Examples

Structure & Pointer Examples

Structure & Functions Examples

Enumeration Examples

Template Examples


List of Programs

Pointer Examples

Memory Management Examples

Pointers and Arrays

Virtual Function Examples

Learn All in Tamil © Designed & Developed By Tutor Joes