Lesson 4 of 24

Conditions: if, else and switch

9 min 25 XP

if / else if / else and switch work just like in C. Combine conditions with && (AND), || (OR) and ! (NOT).

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

Challenge

+25 XP

Read three side lengths. Print "Invalid" if they can't form a triangle; otherwise "Equilateral", "Isosceles" or "Scalene". Input: 3 4 5 → Output: Scalene

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.