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

Username:   Password: 
 RegisterRegister   
 Loops for the Very Beginners!
Index -> Programming, Turing -> Turing Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ZeroPldn




PostPosted: Wed Mar 09, 2005 5:00 pm   Post subject: Loops for the Very Beginners!

mmk, my first post, here it goes...

Basic Loops

ok, for the basic loop, that goes on forever

loop
put "type a number
var number:real
get number
put "the number is "..
put number
end loop

this will keep outputing the number u enter, but u cant stop it unless u exit the harsh way, the top right X button (OMG!)

loop w/ exception

ok, now this is the same as the first, 'cept this one u can end the program when you type a negative number.

loop
put "enter a number"
put "if u enter a negative number, the program will end"
var number:real
get number
end if number<0
put "the number is "..
put number
end loop

ok, this one you can type a number, but as soon as it becomes negative, the program will stop.

thats all for now, if any1 sees an error plz debug as i am ne to this stuff

[/b][/list]
Sponsor
Sponsor
Sponsor
sponsor
Flikerator




PostPosted: Wed Mar 09, 2005 5:13 pm   Post subject: (No subject)

Put all the code in Code tags, like this;

code:
[code][/code]


EDIT

Check your code, it doesn't work..

EDIT AGAIN

Declare vars BEFORE loops. If you want to change the number to a 0 then just;

code:
num := 0


OR since you choose it again do nothing.

EDIT YET AGAIN

Welcome to the compsci forums, if you have any questions feel free to post them ^^;
person




PostPosted: Wed Mar 09, 2005 6:09 pm   Post subject: (No subject)

welcome!!! Smile Smile

anyways most of ur code doesnt work so uv really got to edit some
jamonathin




PostPosted: Thu Mar 10, 2005 6:59 am   Post subject: (No subject)

"end if's" are used for "if" statements, you're going to want "exit when", and put it at the end of the loop, so everything can be run.
ZeroPldn




PostPosted: Thu Mar 10, 2005 3:13 pm   Post subject: (No subject)

omg, im so newbish... aw well i just got turing at my own house so now i can try out the bloddy programs b4 i post them, sry.
person




PostPosted: Thu Mar 10, 2005 3:40 pm   Post subject: (No subject)

i just fixed ur code

code:

loop
    var number : real
    put "type a number "..
    get number
    put "the number is " ..
    put number
end loop


and the second prat

code:

loop
    var number : real
    put "enter a number"
    put "if u enter a negative number, the program will end"
    get number
    put "the number is " ..
    put number
    exit when number < 0
end loop


see...arnt i nice??
jamonathin




PostPosted: Thu Mar 10, 2005 3:45 pm   Post subject: (No subject)

you are the nicest person...person...
Token




PostPosted: Thu Mar 10, 2005 3:49 pm   Post subject: (No subject)

Also it may help to know that the 'exit when' command can be used as many times as neccisary within a loop, and that it can use the and and or statements, just little tidbits that helped me out...
Sponsor
Sponsor
Sponsor
sponsor
ssr




PostPosted: Thu Mar 10, 2005 10:05 pm   Post subject: (No subject)

jamonathin wrote:
you are the nicest person...person...

lol I think he is just as bored as I am
lol
just kidding
just kidding
anyway
no offence but is this supposed to be a tutorial?
Question
well
...
LETS FIX IT UP!! Razz Razz
ssr




PostPosted: Thu Mar 10, 2005 10:10 pm   Post subject: (No subject)

Im srry if I been kinda harsh ZeroPldn
since this was ur first post
umm
Its better than my first post
Wink
there are some errors as mentioned above, fix them and u'd be ok

btw WELCOME! Laughing 8)
ZeroPldn




PostPosted: Sat Mar 12, 2005 9:41 am   Post subject: (No subject)

ok ill fix it then, but since its allready been fixed by person (ty vm), theres no use reposting it. im sry if my first post was such a faliure ill try to be better next time. Embarassed ty person, here, have my bits.
Martin




PostPosted: Sat Mar 12, 2005 10:54 am   Post subject: (No subject)

Hah no worries Smile
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 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: