Operators are the core concepts of any programming language as none of the programming languages can proceed and even exist without the concept of operators. In real life, if we take an example, explaining the Operators in C++ is like we are cooking spicy food. Still, without the spices, we can’t cook delicious food; it’s tasteless, and the same as in C++ without Operators; any mathematical operations are impossible.
What are the operators in c++?
Operators are symbols that perform operations on variables and values or the operands. We use them to perform mathematical and logical equations. For example, + is an operator used for addition, while – is used for subtraction.
Types of operators in c++
C++ divides the operators into 7 parts:
- Arithmetic Operator
- Assignment Operator
- Unary Operator
- Equality Operator
- Relational operator
- Logical Operator
- Bitwise Operator
For a detailed explanation, click on the operators.
Example of operators
#include <iostream>
using namespace std;
int main()
{
// Assignment operator
int a = 5;
int b = 2;
// Arithmentic operator
cout << "a + b = " << (a + b) << endl;
// Unary operator
int result_a = ++a;
cout << "result_a = " << result_a << endl;
// Relational operator
cout << (a > b) << endl;
// Logical operator
cout << ((a != b) && (a < b)) << endl;
// Coumpound operator
a += 5;
cout << a << endl;
// Equality operator
cout << (a == b) << endl;
return 0;
}
OUTPUT
a + b = 7
result_a = 6
1
0
11
0
So here you just an example of operators and many others waiting for you.
FOLLOW-UP
Excellent, you successfully get to know the introduction about the operators, and for more, keep checking the following blogs for explicit crystal knowledge about the operators.
Similarly, you must also know that GeekonPeak has just begun and is looking for some loyal supporters so we, the new-gen geeky friends, can grow and create more comprehensive and easy-to-grasp courses for you (for free). You can follow us on Facebook, Instagram & Twitter as well. Also, don’t miss our newsletter subscription. We provide exclusive blogs, tips, tricks, and advice to program efficiently and market smartly. We also promote some of our partners with excellent experiences to share with you. Until next time 🙂