Operators In C++:
Operators are symbols that perform operations on values and variables.
Operators in C++ can be classified into :
- Arithmetic Operator
- Relational Operator
- Logical Operator
- Bitwise Operator
- Assignment Operator
Arithmetic Operator:
This operator is used to perform arithmetic or mathematical operations on the operands.Program :
#include <iostream>using namespace std;
int main()
{
int a = 40 + 60;
cout << a;
return 0;
}
Output :
100
Relational operator:
Relational operator is used to compare the operand. It is also known as comparison operator.The return value of a comparison is either 1 or 0, that is true (1) or false (0). These values are known as Boolean values.
Program:
#include <iostream>
using namespace std;
int main() {
int a = 5;
int b = 3;
cout << (a > b);
return 0;
}
using namespace std;
int main() {
int a = 5;
int b = 3;
cout << (a > b);
return 0;
}
Output:
1
Logical operator :
Logical operator is used to determine the logic between operands.
Bitwise operator:
- Bitwise operator is used on (binary) numbers.
- It perform operations on integer data at the individual bit.
Assignment operator:
Assignment operator is used to assign values to variables.
Program:
#include <iostream>
using namespace std;
int main() {
int a = 20;
a += 15;
cout << a;
return 0;
}
Output:
35