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

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




PostPosted: Sun Feb 13, 2005 5:48 pm   Post subject: loop question

i've checked the manual and stuff but im still not sure how to do this, i know a few other languages, like C++, java ect, and they all have "while loops" so it loops until something equals something else, how do you do that in turing? and, how do you make it so a new variable is created every time? like i have to make something that asks how many courses you have this semester, then it will ask you what you got in each one and find the average, but i dont know how to make a new variable for each mark, if you are asked how many courses you have
Sponsor
Sponsor
Sponsor
sponsor
Drakain Zeil




PostPosted: Sun Feb 13, 2005 6:05 pm   Post subject: (No subject)

Eh? I think you want to use a for..end for, and an array.
code:

var courses:int

get courses

var grade:array of int 1..courses

for i:1..courses
get grade(i)
end for

Is that what you wanted? (note: I haven't used turing in a while, my code code be off by a bit)
ssr




PostPosted: Sun Feb 13, 2005 6:09 pm   Post subject: (No subject)

Do you want
code:
exit when

code:
var ha :int
loop
get ha
exit when ha = 5
end loop

8) 8)
endusto




PostPosted: Sun Feb 13, 2005 7:36 pm   Post subject: (No subject)

well i want that, but i want it so like, ha1 will be your first mark, ha2 will be your second... ect.
ssr




PostPosted: Sun Feb 13, 2005 8:09 pm   Post subject: (No subject)

then u have to create an array
code:
var times:int
put "how many marks to enter?"
get times

var lala : array 1..times of int

% this part is just in case the user skips a turn
for ii:1..times
lala(ii) := 0
end for

for i:1..times
put "Enter the number ", i ," mark."
get lala (i)
end for

for b:1..times
put "The number ",b, " mark is ",lala (b)
end for
Wink Very Happy
1337_brad




PostPosted: Sun Feb 13, 2005 8:27 pm   Post subject: Uhh...

Turing has while loops o.o; *I think* been a while since I turcoded but I am uite sure it does o.o;
cycro1234




PostPosted: Mon Feb 14, 2005 8:30 am   Post subject: (No subject)

Turing does not have while loops
ssr




PostPosted: Mon Feb 14, 2005 2:55 pm   Post subject: (No subject)

I'm just wondering, is there anyway to create arrays or chnage it
like depends on how many numbers the user entered, teh number of arrays are created. Very Happy Very Happy Very Happy
using loops
and blah blah
8) 8)
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Feb 14, 2005 3:13 pm   Post subject: (No subject)

cycro1234 wrote:
Turing does not have while loops

sure it does
Turing:

loop
...
exit when not(condition)
end loop

Wink
ssr wrote:
something about arrays

yes - Flexible Arrays
ssr




PostPosted: Mon Feb 14, 2005 8:32 pm   Post subject: (No subject)

WOWOWOWOW
thanx Tony,so thats what its for
I was just wondering what a flexible array is. Very Happy Very Happy
StarGateSG-1




PostPosted: Tue Feb 15, 2005 12:20 pm   Post subject: (No subject)

Not to be rude but if you already know some java and C++ why are you leanring turing Question Question Question Arrow

Turing is only good if you don't know any other language at teh time Exclamation Arrow

If it is a school course talk to your teacher about advancing your skills not back tracking 8)
ssr




PostPosted: Tue Feb 15, 2005 4:23 pm   Post subject: (No subject)

I only know a little java and still learning, and I dont know any C++?
ummm
Bacchus




PostPosted: Tue Feb 15, 2005 11:20 pm   Post subject: (No subject)

i think he wa stalking about endusto
ssr




PostPosted: Wed Feb 16, 2005 12:13 pm   Post subject: (No subject)

Blah Embarassed Embarassed
use
Quote:
lalala

anyway I like Turing..
cycro1234




PostPosted: Wed Feb 16, 2005 7:10 pm   Post subject: (No subject)

Turing is great if u've never done ne programming in the past, like me Very Happy
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  [ 15 Posts ]
Jump to:   


Style:  
Search: