C++ Math
➗ C++ Math
C++ mein Math operations do tarah se hote hain:
1️⃣ Basic arithmetic operators
2️⃣ Math library functions (<cmath>)
🔹 1. Basic Math Operators
Floating Division
🔹 2. Math Functions (<cmath>)
Common Math Functions
| Function | Work | Example |
|---|---|---|
sqrt(x) | Square root | sqrt(16) → 4 |
pow(x,y) | Power | pow(2,3) → 8 |
abs(x) | Absolute value | abs(-5) → 5 |
round(x) | Nearest integer | round(4.6) → 5 |
ceil(x) | Round up | ceil(4.2) → 5 |
floor(x) | Round down | floor(4.9) → 4 |
log(x) | Natural log | log(2.7) |
sin(x) | Sine (radians) | sin(0) |
cos(x) | Cosine | cos(0) |
tan(x) | Tangent | tan(0) |
🔹 3. Examples
Square Root & Power
Rounding Functions
Absolute Value
🔹 4. Trigonometry (Radians)
⚠️ Trigonometric functions radians mein kaam karti hain, degrees mein nahi.
🔹 5. Min & Max
❌ Common Mistakes
✔ Correct:
📌 Summary
Basic math →
+ - * / %Advanced math →
<cmath>functionspow,sqrt,round,ceil,floorvery commonTrigonometry uses radians
