
-----------------------------------
Killa Hilla
Mon Mar 03, 2003 9:26 am

Arrays
-----------------------------------
I am new to Turing, What exactly is an Array, ive heard alot about em.  Please provide an Example if you can,

Thanks

Killa

-----------------------------------
CyCLoBoT
Mon Mar 03, 2003 5:58 pm


-----------------------------------
I'm not exactly sure how to define it but I can give u an example.

var number : array 1..10 of int  %Creates 10 number elements

for i : 1..10
number(i) = i %Stores each number in the number element
end for
 

-----------------------------------
Tony
Mon Mar 03, 2003 8:02 pm


-----------------------------------
an array is a group of variables of same time. Such as instead of declearing name1, name2... name10, you can just declear var name:array 1..10 of string

To access each element of the array, you use name(index) where index is the element. Such as 5th name is name(5)

the biggest advantage of an array is ability to use a variable for its index, such as

for i:1..10
put name(i)
end for


this forloop will go through every element in the array and output them on the screen.
