Conditional Statement

In this lesson, you will be introduced to conditional statement.

We'll cover the following

Introduction

As the name implies, conditional statements specify whether another statement or block of statements should be executed or not. These are often called “selection constructs”. The two general types are:

  • “if-then-else”
  • the “switch-case” construct

Comparison operators

The conditions tested are specified using comparison operators. These operators cause the immediate statement in which they are contained to return a Boolean value of either true or false.

Note: In certain circumstances, true and false may be assigned to 1 and 0, respectively. So, be careful while combining conditional statements with arithmetic.

Get hands-on with 1200+ tech skills courses.