1. Operators

A. Arithmetic Operators

Used for math calculations.

int a = 10, b = 3;

cout << a + b;   // 13 (addition)
cout << a - b;   // 7  (subtraction)
cout << a * b;   // 30 (multiplication)
cout << a / b;   // 3  (division)
cout << a % b;   // 1  (remainder/modulo)

Example:

int marks1 = 80, marks2 = 90;
int total = marks1 + marks2;
int average = total / 2;

cout << "Total: " << total << endl;      // 170
cout << "Average: " << average << endl;  // 85


B. Assignment Operators

Used to assign values.

int x = 10;

x = 5;      // x becomes 5
x += 3;     // x = x + 3  → x becomes 8
x -= 2;     // x = x - 2  → x becomes 6
x *= 4;     // x = x * 4  → x becomes 24
x /= 2;     // x = x / 2  → x becomes 12


C. Comparison Operators

Used to compare values. Result is true or false.

int a = 10, b = 5;

a == b    // false (is equal?)
a != b    // true  (is not equal?)
a > b     // true  (is greater?)
a < b     // false (is smaller?)
a >= b    // true  (is greater or equal?)
a <= b    // false (is smaller or equal?)


D. Logical Operators

Combine multiple conditions.

// AND (&&) - Both must be true
true && true    // true
true && false   // false

// OR (||) - At least one must be true
true || false   // true
false || false  // false

// NOT (!) - Reverses
!true    // false
!false   // true