Mask-group

Nested if-else Statement



  • We can write an entire if-else construct within either the body of the if statement or the body of the else statement. This is known as nesting.

  • The if statement can take any of the following forms:

  1. if (condition)

do this;

if (condition)

{

do this;

and this;

}

if (condition)

do this;

else

do this;

  1. if (condition)

{

do this;

and this;

}

else

{

do this;

and this;

}

if (condition)

do this;

else

{

if (condition)

do this;

else

do this;

}

  1. if (condition)

{

if (condition)

do this;

else

{

do this;

and this;

}

}

else

do this;

  • Example: