Simple Logical Operators Example Program In C++
Logical Operators
- AND, OR operators are used when we want to use two or more Conditions.
Types Of Logical Operators
- && Logical AND
- || Logical OR
- ! Logical NOT
Logical And (&&) Operator
Logical And Operator Definition
If both the operations are successful, then the condition becomes true.
Logical And Operator Syntax
expr1 && expr2
Logical And Operator Syntax Example
if( (a>10) && (a<20) )
printf(?A is in-between of 10 and 20?);
Logical And Operator Example Program
// Header Files
#include<iostream>
#include<conio.h>
//Main Function
using namespace std;
int main ()
{
// Variable Declaration
int num1 = 30,num2 = 40;
//int num1 = 50,num2 = 80;
cout << "Simple Logical Operators Example Program \n";
if(num1>=40 && num2>=40){
printf("Num 1 and Num 2, both are greater than or equal to 40");
}
if(num1>=40 || num2>=40){
printf("Num 1 or Num 2 is greater than or equal to 40");
}
// Wait For Output Screen
getch();
//Main Function return Statement
return 0;
}
Sample Output
Simple Logical Operators Example Program
//if num1 = 30,num2 = 40
Num 1 or Num 2 is greater than or equal to 40
//int num1 = 50,num2 = 80;
Num 1 and Num 2, both are greater than or equal to 40
C++ Operator Example Programs
- Simple Arithmetic Operators Example Program In C++
- Simple Relational Operator Example Program In C++
- Simple Logical Operators Example Program In C++
- Simple Assignment Operators Example Program In C++
- Simple Unary Operators Example Program In C++
- Simple Conditional or Ternary Operators Example Program In C++
- Simple Comma Operators Example Program In C++
- Simple Scope Resolution Operator Example Program In C++
- Simple new Memory Allocation Operator Example Program In C++
- Simple delete Memory Releasing Operator Example Program In C++
Read More Articles
- Simple Merge Sort Program in C++
- Scope Resolution Operator In C++
- Simple Program for Virtual Functions Using C++ Programming
- Simple Class Example Program For Find Prime Number In C++
- Simple Example Program For Parameterized Constructor In C++
- Define Constructor in Outside Class Example Program In C++
- Simple Program for Function Overloading Using C++ Programming
- Simple Program for Single Inheritance Using C++ Programming
- Simple Example Program For Copy Constructor In C++
- Simple Program for Inline Function without Class Using C++ Programming
- Simple Example Program For Constructor Overloading In C++
- Simple Example Program for Inline Function Using C++ Programming
- Factorial Using Function Example Program In C++
- Simple Addition ( Add Two Integers ) Example Program
- Simple Example Program For Constructor In C++
- Simple Stack Program in C++ Programming
- Simple Program for Read user Input Using cin
- Factorial Using Loop Example Program In C++
- Simple Program for Friend Function Using C++ Programming
- Simple Program for Static Data and Member Function Using C++ Programming
- Simple Program for Multiple Inheritance Using C++ Programming
- Simple Program for Unary Operator Overloading Using C++ Programming
- Simple Copy Constructor Example Program For Find Factorial In C++
- Do While Loop Example Program In C++
- Simple Program for Function Template Using C++ Programming