If Statement

Programs that we wrote so far have been executed in a sequential order. This means that each line of code is executed one after another. However, in many cases, we need to execute a block of code only if a certain condition is met. For example, we may want to print a message only if a user is logged in. In this case, we need to use an if statement.