Site pages
Current course
Participants
General
Topic 1
Topic 2
Topic 3
Topic 4
Topic 5
Topic 6
Topic 7
Topic 8
Topic 9
Topic 10
Topic 11
Topic 12
Topic 13
Topic 14
Topic 15
Topic 16
Topic 17
Topic 18
Topic 19
Topic 20
Topic 21
Topic 22
Topic 23
Topic 24
Topic 25
Topic 26
Topic 27
Topic 28
Topic 29
Topic 30
Topic 31
Topic 32
Topic 33
Topic 34
Topic 35
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 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