Author |
Message |
heesoup
|
Posted: Thu May 28, 2009 6:53 pm Post subject: Help-repetition |
|
|
What is it you are trying to achieve?
I AM TRYING TO HAVE THE QUESTION MARK REPEAT 50 TIMES USING LOOP
IS THERE A WAY I CAN DO THAT?
PLEASE HELP ASAP
THANKS
What is the problem you are having?
I can only seem to do this with number operations....
Describe what you have tried to solve this problem
I tried everything. Trust me.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
loop
for count:1..50
put "?"
end for
end loop
|
Please specify what version of Turing you are using
4.1.1 I think... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
nonamedude
|
Posted: Thu May 28, 2009 7:20 pm Post subject: Re: Help-repetition |
|
|
it works.... |
|
|
|
|
|
Dusk Eagle
|
Posted: Thu May 28, 2009 7:31 pm Post subject: Re: Help-repetition |
|
|
Let me trace your program for you: Ok, so whatever we do from now until the "end loop" will be repeated again and again indefinitely.
Turing: |
for count:1..50
put "?"
end for
| For 50 times we output a question mark, each on a new line. (To make them all appear on one line we must put a double-dot [ .. ] at the end of the line.)
Hop back up to the "loop" line and do everything all over again!
I'm not exactly sure what your problem is here, but hopefully you can correct your error on your own after seeing it mapped out for you. If not, feel free to leave a reply stating more clearly what your problem is. |
|
|
|
|
|
heesoup
|
Posted: Thu May 28, 2009 7:41 pm Post subject: Re: Help-repetition |
|
|
Dusk Eagle @ Thu May 28, 2009 7:31 pm wrote: Let me trace your program for you: Ok, so whatever we do from now until the "end loop" will be repeated again and again indefinitely.
Turing: |
for count:1..50
put "?"
end for
| For 50 times we output a question mark, each on a new line. (To make them all appear on one line we must put a double-dot [ .. ] at the end of the line.)
Hop back up to the "loop" line and do everything all over again!
I'm not exactly sure what your problem is here, but hopefully you can correct your error on your own after seeing it mapped out for you. If not, feel free to leave a reply stating more clearly what your problem is.
okay...so what I am actually trying to do is to put the 50 question marks right beside each other in one line or a few more....
like this
??????????????????????????????????????????????????????????????????????
but it seems like whenever I run it, there is an infinite amount of them.. |
|
|
|
|
|
heesoup
|
Posted: Thu May 28, 2009 7:43 pm Post subject: Re: Help-repetition |
|
|
and I am not allowed to manually type out 50 "?"s
I have to use "repetition" |
|
|
|
|
|
tjmoore1993
|
Posted: Thu May 28, 2009 7:57 pm Post subject: Re: Help-repetition |
|
|
heesoup @ Thu May 28, 2009 7:43 pm wrote: and I am not allowed to manually type out 50 "?"s
I have to use "repetition"
I haven't read the post but using a for statement is highly effective.
Turing: | for column : 1 .. maxcol
locate (20, column )
put "?" ..
end for
|
or
Turing: | for column : 1 .. 50
locate (20, column )
put "?" ..
end for
|
|
|
|
|
|
|
Dusk Eagle
|
Posted: Thu May 28, 2009 8:03 pm Post subject: Re: Help-repetition |
|
|
There are many ways to do what you want. A very good way, as it is more applicable to a larger variety of problems is to simply put a .. after your string. Like this:
This keeps the next outputted string on the same line as the previous.
You could also use a repeat statement, shown below, but since that does not teach you how to properly use for loops I doubt it is the method your teacher wants.
|
|
|
|
|
|
heesoup
|
Posted: Thu May 28, 2009 8:04 pm Post subject: Re: Help-repetition |
|
|
WOW THANKS EVERYONE!
I figured it out now!!! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
tjmoore1993
|
Posted: Thu May 28, 2009 8:04 pm Post subject: Re: Help-repetition |
|
|
heesoup @ Thu May 28, 2009 8:04 pm wrote: WOW THANKS EVERYONE!
I figured it out now!!!
Good luck with whatever you were doing |
|
|
|
|
|
|