Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements