C++ Assignment Operators
π C++ Assignment Operators
Assignment Operators ka use variable ko value assign karne aur update karne ke liye hota hai.
πΉ 1. Basic Assignment (=)
πΉ 2. List of Assignment Operators
| Operator | Example | Meaning |
|---|---|---|
= | a = 5 | Assign value |
+= | a += 3 | a = a + 3 |
-= | a -= 2 | a = a - 2 |
*= | a *= 4 | a = a * 4 |
/= | a /= 2 | a = a / 2 |
%= | a %= 3 | a = a % 3 |
πΉ 3. Examples
β += (Addition Assignment)
Output: 15
β -= (Subtraction Assignment)
Output: 7
βοΈ *= (Multiplication Assignment)
Output: 20
β /= (Division Assignment)
Output: 5
π %= (Modulus Assignment)
Output: 1
πΉ 4. Combined Example Program
β Common Mistake
β Correct:
π Summary
Assignment operators value assign & update karte hain
Short & readable code likhne mein help karte hain
%=sirf integer types ke liye
