if Statements

In this lesson, we will learn about if statements.

While writing a program, you may have to change the flow of the code depending on certain conditions and inputs.

For example, if we are dealing with numbers in our program we may want to print “positive” if the number we received is a positive integer.

Here, we will have to write a condition that tells us to print “positive” if we receive a positive number.

For such a situation, we need Conditional statements.

What are Conditional Statements?

Conditional statements are used in programming languages to perform different computations or actions depending on whether a certain condition is met.

Let’s have a look at an example:

Create a free account to access the full course.

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