If-else Statement

In this lesson, you will get acquainted with the if-else statement in C++.

Introduction

Suppose you can buy a watch for your friend if you have at least $20. Otherwise, you can gift them a pen.

In C++, we can demonstrate this kind of behavior using the if-else statement.

In the if-else statement, when the condition in an if statement evaluates to false, the compiler executes the code inside the else block. ... ...