Operators in C++
6 Types of Operators in C++
- Arithmetic Operators
- Assignment Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Other Operators
Arithmetic Operator
basic adding, subtracting, multiplication, etc
example:
#include <iostream>
using namespace std;
int main() {
int d, b;
d = 10;
b = 2;
cout << "d + b = " << (d + b) << endl;
return 0;
}
Increment and Decrement Operators
++ and – increase and decreases the value by 1
#include <iostream>
using namespace std;
int main() {
int a = 10;
int b = 10;
a++;
b--;
cout << "a incremented by 1: " << a << endl;
cout << "b decremented by 1: " << b << endl;
return 0;
}
Assignment Operators
Relational Operators
== !=
Logical Operators
&& : AND
: OR |
! : NOT