Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Arrays
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Killa Hilla




PostPosted: Mon Mar 03, 2003 9:26 am   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
CyCLoBoT




PostPosted: Mon Mar 03, 2003 5:58 pm   Post subject: (No subject)

I'm not exactly sure how to define it but I can give u an example.

code:
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




PostPosted: Mon Mar 03, 2003 8:02 pm   Post subject: (No subject)

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
code:

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: