C++ If β¦ Else Statement
π C++ If β¦ Else Statement
if...else statement ka use conditions ke basis par decision lene ke liye hota hai.
Agar condition true hoti hai to if ka block run hota hai, warna else ka.
πΉ 1. Basic if Statement
πΉ 2. if...else Statement
πΉ 3. if...else if...else Ladder
πΉ 4. Multiple Conditions (Logical Operators)
πΉ 5. Nested if...else
πΉ 6. if without Braces {}
β οΈ Multiple statements ke liye braces zaroori hain.
πΉ 7. Ternary Operator (Short if...else)
β Common Mistakes
β Correct:
π Summary
-
ifβ condition true ho to -
elseβ condition false ho to -
else ifβ multiple conditions -
Logical operators combine conditions
-
Ternary = short form of
if...else
