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


This publication is copyright Learning Systems 1997
and may not be reproduced by any means without the written
permission of Learning Systems.
P.O. Box 32, Mowbray, Tasmania, Australia