If...else Statement
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
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/2dd9fc5e-6828-4ce8-88fd-a3215710781f/Section_4/JS_else%404x-8.png)
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
Everything was clear?
Course Content
C++ Introduction
4. Introduction to Program Flow
5. Introduction to Functions
C++ Introduction
If...else Statement
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
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/2dd9fc5e-6828-4ce8-88fd-a3215710781f/Section_4/JS_else%404x-8.png)
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
Everything was clear?