An if statement is a way of telling a computer to only perform a specific task under some circumstances. It is considered a conditional statement.
If statments, depending on the language you use, consist of ‘if’, ‘if else’ and ‘else’. You can have as many ‘if else’ parts as you like, but only one ‘if’ at the beginning, and one ‘else’ at the end.
You don’t have to use the ‘else if’, or even the ‘else’ parts, you could just use an ‘if’ on its own.
In a very basic real life example, when making a cup of tea for someone, sugar is only added to the tea if it is wanted, therefore sugar is added on the condition that the person you asked said yes to sugar.
if "do you want sugar in your tea?" = "yes" then add sugar to the tea else do not add sugar to the tea
You can complicate this by considering how many spoons of sugar a person would like.
if "how many lumps of sugar would you like in your tea?" = "1 lump" then add 1 lump of sugar to the tea else if "how many lumps of sugar would you like in your tea?" = "2 lumps" then add 2 lumps of sugar to the tea else if "how many lumps of sugar would you like in your tea?" = "I do not want any sugar" do not add sugar to the tea
Notice there is no final ‘else’ in this example – you cannot assume that an answer that is not 1 lump or 2 lumps necessarily means that they do not want sugar at all – they may want 3 lumps, or perhaps sweetener. This is a very basic example though, and would not be the best method of dealing with this situation.