Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
If...else Statement | Introduction to Program Flow
C++ Introduction

If...else StatementIf...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:

cpp

main.cpp

Here, we use the 2-lines comment.

There is also a handling of the "opposite" case using else:

cpp

main.cpp

There can be other if...else inside the if...else:

cpp

main.cpp

You can also use the else if construct:

cpp

main.cpp

What will the program output?

Selecione a resposta correta

Tudo estava claro?

Seção 4. Capítulo 1
course content

Conteúdo do Curso

C++ Introduction

If...else StatementIf...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:

cpp

main.cpp

Here, we use the 2-lines comment.

There is also a handling of the "opposite" case using else:

cpp

main.cpp

There can be other if...else inside the if...else:

cpp

main.cpp

You can also use the else if construct:

cpp

main.cpp

What will the program output?

Selecione a resposta correta

Tudo estava claro?

Seção 4. Capítulo 1
some-alt