The DATA statement

The DATA statement
    The DATA statement gets the data values from the input device and stores them in the computer memory. The format of this statement is
    The_DATA_statement.jpg
    where
    d1, d2, d3… are the data values.
    Eg :
    28 DATA 2, 13, -4, 20.5
    29 READ A, B, C, D
    The assignment of values to the variables is: to start with, the pointer is at the value 2; 2 becomes the value of A. then the pointer moves to 13 and this becomes the value of B. After this, the pointer points to -4 and this is assigned to variable C. Next, the pointer goes to 20.5 and this becomes the value of D. the values 2, 13, -4, 20.5 stay unchanged in the computer memory.There may be as many DATA statement in a program as are desired. They may be placed anywhere but always before the END statement.
    Eg:
    10 DATA 2.2, -3.0, 5
    20 READ P,Q
    30 DATA 8, 9.67
    40 READ R
    50 READ S,T
    To start with, the pointer is at value 2.2. When the READ statement at line 20 is executed, P is assigned the value 2.2 and Q is assigned the value -3.0. Now the pointer is at value 5. When the READ statement at line 40 is executed, R gets the value 5 and the pointer moves to the next value 8. Values 8 and 9.67 are assigned to the variables S and T after the execution of the READ statement at line 50.

Last modified: Wednesday, 18 January 2012, 11:05 PM