Author |
Message |
ZeroPldn
|
Posted: 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
|
|
|
Flikerator
|
Posted: Wed Mar 09, 2005 5:13 pm Post subject: (No subject) |
|
|
Put all the code in Code tags, like this;
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;
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
|
Posted: Wed Mar 09, 2005 6:09 pm Post subject: (No subject) |
|
|
welcome!!!
anyways most of ur code doesnt work so uv really got to edit some |
|
|
|
|
|
jamonathin
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: Thu Mar 10, 2005 3:45 pm Post subject: (No subject) |
|
|
you are the nicest person...person... |
|
|
|
|
|
Token
|
Posted: 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
|
|
|
ssr
|
|
|
|
|
ssr
|
Posted: 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
there are some errors as mentioned above, fix them and u'd be ok
btw WELCOME! 8) |
|
|
|
|
|
ZeroPldn
|
Posted: 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. ty person, here, have my bits. |
|
|
|
|
|
Martin
|
Posted: Sat Mar 12, 2005 10:54 am Post subject: (No subject) |
|
|
Hah no worries |
|
|
|
|
|
|