Operator Types
int a = 10;
int b = 5;
int c = 0;
main {
// assignment operators
c = 5; // c is set to a value of 5
c += 5; // c is set to a value of 10 (5 + 5 = 10)
c -= 5; // c is set to a value of 5 (10 - 5 = 5)
c *= 5; // c is set to a value of 25 (5 * 5 = 25)
c /= 5; // c is set to a value of 5 (25 / 5 = 5)
c %= 5; // c is set to a value of 0 (5 % 5 = 0)
// mathematical operators
c = a + b; // addition, c = 15
c = a - b; // subtraction, c = 5
c = a * b; // multiplication, c = 50
c = a / b; // division, c = 2
c++; // increment, c = 3
c--; // decrement, c = 2
// logical operators
if(c != a) // NOT: if c is not equal to a
if(a && c) // AND: if a and c are true
if(a || c) // OR: if a or c are true
if(a ^^ c) // XOR: if either a or c are true but not both
// relational operators
if(c == 10) // equal to: if c is equal to 10
if(c != 50) // not equal to: if c is not equal to 50
if(c < 20) // less than: if c is less than 20
if(c > 30) // greater than: if c is greater than 30
if(c <= 40) // less than or equal to: if c is less than or equal to 40
if(c >= 40) // greater than or equal to: if c is greater than or equal to 40
}Assignment
Operator
Description
Arithmetic
Operator
Description
Logical
Operator
Description
Relational
Operator
Description
Binary
Operator
Description
Last updated

