In layman's terms, how do you explain the logic in an 'if' statement inside another 'if' statement?

Home » Programming & Design » In layman's terms, how do you explain the logic in an 'if' statement inside another 'if' statement?
Programming & Design No Comments

Other answer:

Brandon:
An if inside an if is a way to test two conditions at once.
One could also describe it as walking along a path that branches, then branches again.
Hodges:
An if inside an if is a way to test two conditions at once.
One could also describe it as walking along a path that branches, then branches again.
EddieJ:
With one level (an ordinary if statement) you could say:

If you are a man, go to men's washroom, otherwise go to the women's restroom.

However, if you need to add more detail, you can replace "go to men's washroom" with a nested if statement.

If you only need to urinate, use urinal, otherwise use toilet in stall.

You could go further. For instance, you can ask if you are handicapped and then have additional nested logic for that.

Allan:
An if inside an if is a way to test two conditions at once.
One could also describe it as walking along a path that branches, then branches again.
?:
OK.. imagine a building with two doors. one is an exit and the other leads to a room with two more doors. so depending on what door you select first will influence what happens next. if you choose to exit then that's it, but if you choose to take the other door then upon entering the room you can now make another choice as to which door you take.
if you have a third if statement then imagine that one of these two doors will also lead to another room with two doors.. and so – on..

I hope that makes sense..

Chris:
An if inside an if is a way to test two conditions at once.
One could also describe it as walking along a path that branches, then branches again.
cpcii:
Example,
If your Last name is smith
..if your first name is john
….do this 1 thing
..else
….do this 2 thing
..end if
else
..do this 3 thing
end if
Richard:
If you are going outside then
….if it is raining then
……..wear a raincoat
….else
……..leave the raincoat at home
….End if
else
….Sit down and watch the TV
End if

LEAVE A COMMENT