3GL Program Design - Nassi-Schneiderman diagrams

Exercise 1

Sketch NS diagrams for the following pseudocode fragments:
 
(1) 

IF x = = 100 
 THEN IF x = = 120 
   THEN IF x = = 140 
               THEN DISPLAY 'A' 
               ELSE DISPLAY 'B' 
   ELSE DISPLAY 'C' 
 ELSE DISPLAY 'D' 
ENDIF

(2) 

X = 1 
REPEAT 
 X = X + 1 
 DISPLAY X 
UNTIL X > 10

(3) 

X = 0 
DOWHILE X < 10 
 DISPLAY X 
 X = X + 1 
END WHILE

 
1.  This is an example of a multiway selection.
2. A simple case of a repeat loop. The processes X = X + 1 and DISPLAY X will be repeated until X is greater than 10.
3. A case of a nested loop, a repeat loop within a while loop.



Return to the lesson


and may not be reproduced by any means without the written

 
 

This publication is copyright David Beech and Learning Systems 1997-2002
and may not be reproduced by any means without the written permission of
David Beech.
9 Wyndella Street, Tasmania, Australia


db@codelearn.com