else…..if ladder statement is used to take multi way decision. This statement is formed by joining if ……..else statements in which each else contains another if ….else. The general form is
Computer executes this statement from top to bottom. if a true test condition is found, the statement block associated with it is executed. Then the control is transferred to the next statement. When all the test conditions are false, then the final else containing the default statement will be executed.
Rules
1. The brackets around the test condition are must.
2. The test conditions must be a relational or logical expression.
3. Statement blocks are called body of the if………else statement. It can contain one or more statements.
4. The opening statement and closing brackets {} are must if the statement blocks contain more than one statement. Else optional
5. No statements other than the statements in the statement blocks are allowed between if ….. else.
6. Default statement is a must. If not present no action will take place if all conditions are false.
Flow diagram
No comments:
Post a Comment