
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Written version of Logical operators in C++
In c++ programming language, there are keywords that can be used in place of logical operators. The keywords are initially used in c when the keyboards didn’t support symbols like &&, !, ||, etc. Now, here are some written version of logical operators in c++.
Operators and their written versions are −
Operator | Symbols | Written version |
---|---|---|
And operator | && | and |
Or operator | || | or |
Not operator | ! | not |
Not equal to operator | != | not_eq |
Bitwise and operator | & | bitand |
Bitwise or operator | | | bitor |
Bitwise XOR operator | ^ | |
And equal to operator | &= | and_eq |
Or equal to operator | |= | or_eq |
XOR equal to operator | ^= |
Program to show the implementation of our program
Example
#include<iostream> using namespace std; int main(){ int x=1, y=0; cout<<"Written logical operators are :\n"; cout<<x<<" and "<<y<<" = "<<(x and y)<<endl; cout<<x<<" or "<<y<<" = "<<(x or y)<<endl; cout<<x<<" bitwise and "<<y<<" = "<<(x bitand y)<<endl; cout<<x<<" not equal to "<<y<<" = "<<(x not_eq y)<<endl; return 0; }
Output
Written logical operators are : 1 and 0 = 0 1 or 0 = 1 1 bitwise and 0 = 0 1 not equal to 0 = 1
Pros and cons of using written operators −
Pro − improves the readability of the code.
Pro − it is useful when used with the keyboard that does not support characters like |, &, !, etc.
Cons − using written keywords in a statement, needs space between operators and operands otherwise error might occur.
- Related Articles
- Logical Operators in C++
- Python Logical Operators
- Java Logical Operators
- Perl Logical Operators
- Relational and Logical Operators in C
- Logical Operators on String in Python?
- What are Logical Operators in JavaScript?
- Logical Operators on String in C#
- Logical Operators on String in Java
- Explain the logical operators in DBMS
- What types of logical operators are in javascript?
- Java Regular expressions Logical operators
- What are the logical operators in Java?
- What are the logical operators in C#?
- How to implement relational and logical operators in JShell in Java 9?

Advertisements