...

/

If Expression

If Expression

This lesson teaches multiple conditional constructs using if statement.

There can be multiple conditional constructs using an if statement.

  • If expression

  • If…else expression

  • If…else if…else expression

  • Nested if expression

  • Shorthand if expression

Let’s discuss each one of them in detail:-

If Expression #

If expression takes a condition. If the condition within the if expression evaluates to be true, then the block of code is executed.

Syntax #

The general syntax is:

Illustration #

The following flow chart explains the concept of an if ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy