Operators in C++
An operator is a symbol that tells the compiler to perform specific mathematical, relational, or logical manipulations on values or variables. The data values that operators act upon are called operands.
C++ provides a rich set of built-in operators classified by their functionality and the number of operands they require (unary, binary, or ternary).
Video Explanation

1. Arithmetic Operators
Arithmetic operators execute standard mathematical operations. These require numerical operands.
| Operator | Operation | Mathematical Description | Example (x=10, y=3) | Result |
|---|---|---|---|---|
+ | Addition | Sum of two values | x + y | 13 |
- | Subtraction | Difference between two values | x - y | 7 |
* | Multiplication | Product of two values | x * y | 30 |
/ | Division | Quotient of division | x / y | 3 (Integer truncation) |
% | Modulus | Remainder of an integer division | x % y | 1 |
Note on Division
When both operands are integers (int), the / operator performs integer division, discarding any fractional remainder. To get a decimal result, at least one operand must be a floating-point type (e.g., 10.0 / 3).
ArithmeticOperators.cpp
#include <iostream>
int main() {
int x = 10, y = 5;
std::cout << (x + y) << "\n"; // Output: 15
std::cout << (x / y) << "\n"; // Output: 2
std::cout << (x % y) << "\n"; // Output: 0
return 0;
}