previous | start | next

## The `if/else` Statement

- The `if/else` consists of a condition of two alternatives.
  - The first condition is performed is the condition is true.
  - The second condition is performed if the condition is false.

  >     if (area >= 0)
  >        cout << "The side length is " << sqrt(area) << "\n";
  >     else
  >        cout << "Error: Negative area.\n";

- The `if/else` statement is a better choice than a pair of `if` statements with complementary conditions.

  >     if (area >= 0) /* complementary conditions */
  >        cout << "The side length is " << sqrt(area) << "\n";
  >     if (area < 0) /* complementary conditions */
  >        cout << "Error: Negative area.\n";

previous | start | next