explain about nested if structure with suitable example.
Answers
Answer:
In this example of nested if-else, it first tests Condition1, if this condition is TRUE then it tests Condition2, if Condition2 evaluates to TRUE then Statement1 is executed otherwise Statement2 will be executed. Similarly, if Condition1 is FALSE then it tests Condition3, if Condition3 evaluates to TRUE then Statement3 is executed otherwise Statement4 is executed. The working of nested if-else presented in this example can be further illustrated by following flowchart.
Answer:
And final nested if or else to check for the true condition. The flow of execution goes in a way that condition 1 will get tested if it becomes false then, statement 3 will get executed. If the condition 1 gets satisfied i.e. if it gets true then it will go for the next execution of test condition 2.