9.Selection(B) - Multi Way Selection • You can choose...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Multi Way Selection • You can choose statement(s) to run from many sets of choices. • There are two cases for this: (a) Multi way selection by nested IF structure (b) Multi way selection by SWITCH structure Multi Way Selection by Nested IF Structure • The structure that contains another structure of the same type is called a nested structure. • In the Nested IF structure, the statements that exists between IF and ELSE or between IF and END IF can contain IF statement. Multi Way Selection by Nested If Structure .. Cont. • Syntax of one possible structure: IF ( condition1 ) THEN Statements1 ELSE IF ( condition2 ) THEN Statements2 ELSE IF ( Condition3 ) THEN Statements3 ELSE IF ( Condition4 ) THEN Statements4 END IF END IF END IF Note: The nest can be to many levels. The following figure shows the execution of this structure. Multi Way Selection by Nested If Structure .. Cont. Condition1 Condition2 Statements2 Statements3 Rest of algorithm Statements1 Condition3 Statements4 True True True False False False Multi Way Selection by Nested If Structure .. Examples • Example 4: Write an algorithm that inputs a student mark and outputs the corresponding grade, where grades are as follows: mark grade 90-100 A 80-89 B 70-79 C 60-69 D < 60 E Example 4 .. Cont. 1- Analysis stage : • Problem Input:- student’s mark, mark • Problem Output:- grade • Criteria- according to the previous grade table Example 4 .. Cont....
View Full Document

This note was uploaded on 02/23/2011 for the course CHEMICAL E 2 taught by Professor Hibasaadeh during the Spring '11 term at University of Jordan.

Page1 / 18

9.Selection(B) - Multi Way Selection • You can choose...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online