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

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




PostPosted: 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
Sponsor
sponsor
nonamedude




PostPosted: Thu May 28, 2009 7:20 pm   Post subject: Re: Help-repetition

it works....
Dusk Eagle




PostPosted: Thu May 28, 2009 7:31 pm   Post subject: Re: Help-repetition

Let me trace your program for you:
Turing:

loop
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.)
Turing:

end loop
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




PostPosted: 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:
Turing:

loop
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.)
Turing:

end loop
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




PostPosted: 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




PostPosted: 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




PostPosted: 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:
Turing:

put "?" ..

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.

Turing:

put repeat ("?",50)
heesoup




PostPosted: Thu May 28, 2009 8:04 pm   Post subject: Re: Help-repetition

WOW THANKS EVERYONE!
I figured it out now!!! Very Happy
Sponsor
Sponsor
Sponsor
sponsor
tjmoore1993




PostPosted: 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!!! Very Happy


Good luck with whatever you were doing Smile
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  [ 9 Posts ]
Jump to:   


Style:  
Search: