About Lesson
Nested if-else statement
When a series of decisions are involved, we may have to use more than on if-else statement in nested form. If –else statements can also be nested inside another if block or else block or both.
Syntax :
if(condition-1)
{
if (condition-2)
{
statement-1;
}
else
{
statement-2;
}
}
else
{
statement-3;
}
statement-x;
Else if ladder
The if else-if statement is used to execute one code from multiple conditions.
Syntax :
if( condition-1)
{
statement-1;
}
else if(condition-2)
{
statement-2;
}
else if(condition-3)
{
statement-3;
}
else if(condition-n)
{
statement-n;
}
else
{
default-statement;
}
statement-x;
Practical Exercise: Click Here