Course Content
Introduction to C++
Introduction to C++
if...else
The if...else
construct in programming allows your program to take different paths and manage various potential outcomes.
It consists of two essential components: a condition and the corresponding actions or consequences based on that condition.
Here's an illustration:
main.cpp

Here, we use the 2-lines comment.
There is also a handling of the "opposite" case using else
:
main.cpp
There can be other if...else
inside the if...else
:
main.cpp
You can also use the else if
construct:
main.cpp
What will the program output?
Select the correct answer
Everything was clear?
Section 4. Chapter 1