Basic if statement
if(condition1)
{
//statements to be executed if condition1 is true
}
/* If there is one line of code inside the if block, we can use the following*/
if(condition1)
//single line statement to be executed if condition1 is true
if-else statement
if(condition1)
{
//statements to be executed if condition1 is true
}
else
{
//statements to be executed if condition1 is false
}
if-else if-else statement
In this structure, the if statement is the only one that is required. Both the else if and else statements are optional. You can have as many else if statements as you want; but you can only have at most one else statement.
if(condition1)
{
//statements to be executed if condition1 is true
}
eles if(condition2)
{
//statements to be executed if condition1 is true
}
...
else
{
//statements to be executed if condition1 is false
}