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

Username:   Password: 
 RegisterRegister   
 [Tutorial] Arrays
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jekate




PostPosted: Mon Mar 08, 2004 8:20 pm   Post subject: (No subject)

I got eh first part of the arrat stuff but the second part is confusing.

for i : 1..200
names(i) = " "
end for

is where i got lost.
pls help.
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Mon Mar 08, 2004 8:21 pm   Post subject: (No subject)

it gives all 200 of the variables in the names array the value of " "
Jekate




PostPosted: Tue Mar 09, 2004 8:19 pm   Post subject: (No subject)

ok so if i got

for i : 1..200
names(i) = " "
end for

Then I got 200 variables and the value of each variable is whatever I put inbetween the " " correct?

so what if I need to change the variables in the program for example

i need each "i" variable to add 1 each time in a loop like this

i(1) = i(1) + 1


will that work?
AsianSensation




PostPosted: Tue Mar 09, 2004 8:25 pm   Post subject: (No subject)

i(1) = i(1) + 1 increases whatever value i(1) used to have by 1. So if that's what you want, then yes. But notice, if you ran that in a loop, only i(1) will be increased. If you want every element in the array to increase, then you have to do this

for rep: 1..100
i(rep) := i(rep) + 1
end for
Jekate




PostPosted: Tue Mar 09, 2004 8:32 pm   Post subject: (No subject)

ok. I got another problem:

for count : 1..58
name(count) = "0"
end for


it says "name has not been declared"
"count has not been declared"
AsianSensation




PostPosted: Tue Mar 09, 2004 8:36 pm   Post subject: (No subject)

Turing editor is really helpful, cuz it tells you what problem you have and you can see it instantly.

"name not declared" simply means you didnot declare a variable of and array of strings called name. Also, to assign stuff in turing, it's ":=" instead of "="
Jekate




PostPosted: Tue Mar 09, 2004 8:40 pm   Post subject: (No subject)

I think that's what I got. At the top of the program, the title of it says:

OOT Editor - Object Oriented Turing (3.1.1A (32-bit))
SuperGenius




PostPosted: Wed Mar 10, 2004 10:36 pm   Post subject: (No subject)

you know dodge, if you're a patient man you could land a job teaching my comp sci class easy. Sure, the pay might not be the best but you get to own the leafs... and the raptors... but no one cares about them.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Mar 10, 2004 10:39 pm   Post subject: (No subject)

Laughing

you could teach a compsci class just by printing out tutorials from compsci.ca and handing them out Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
recneps




PostPosted: Thu Mar 11, 2004 4:04 pm   Post subject: (No subject)

Sadly, some of the tutorials here teach me more than my teacher did, just one of em. Whats with teachers these days? :/
Cervantes




PostPosted: Thu Mar 11, 2004 4:27 pm   Post subject: (No subject)

my teacher taught me relatively little but he's still a great teacher. Compsci is not about learning the syntax of various commands, learning how to use the commands, and learning how to combine various commands and techniques to make a program. Compsci is about doing all that as much as you can by yourself, and about solving your own problems. Compsci teachers should are not like math teachers who stand by the chalkboard and teach concepts and run through various questions. Compsci teachers are more of a guide for students.
bevoyleick




PostPosted: Wed Mar 17, 2004 10:12 am   Post subject: (No subject)

i don't really understand the upper and under part; were those the lines that tells the comp which # are in the upper range/lower range, or is it a predefined command?
AsianSensation




PostPosted: Wed Mar 17, 2004 2:21 pm   Post subject: (No subject)

upper returns the higher bound of array. so
code:
var name : array 4 .. 17 of string
put upper (name)
will output 17 to the screen. This is usually used to keep track of the number or positions of elements in an array.

Similarly, lower returns the lower bound of the array, so in the above example, it will return 4.
Viper




PostPosted: Fri Nov 26, 2004 12:29 pm   Post subject: (No subject)

wow after reading this i jus got more confused
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 29 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: