Structured Programming in Basic Problems

© 1998 by Dr. Thomas W. MacFarland -- All Rights Reserved


     Instructions:   Review the following program and see if you can 
                     predict the outcome by completing a "pencil 
                     trace" of the code.  

                     Program output is provided at the end of this 
                     page.

     Compiler:       The program was prepared using GWBasic, which  
                     requires the use of line numbers.


10 REM This program demonstrates READ and DATA statements.
20 FOR X = 1 TO 4
30   READ Y$, Z$
40   PRINT Y$, Z$
50 NEXT X
99 END
100 DATA DEF, P08
101 DATA ABC, X12
102 DATA XYZ, Z23
103 DATA LMN, U99
104 DATA CSE, X89
105 DATA GEM, E01  ' Notice how there are more than 4 sets of data.
10000 REM And the answer is ...
10010 REM DEF           P08
10020 REM ABC           X12
10030 REM XYZ           Z23
10040 REM LMN           U99

Please send comments or suggestions to Dr. Thomas W. MacFarland

There have been visitors to this page since February 1, 1999.