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

Username:   Password: 
 RegisterRegister   
 How do I get turing to repeat a string a certain amount of times?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gayden




PostPosted: Thu Feb 19, 2015 10:41 am   Post subject: How do I get turing to repeat a string a certain amount of times?

So, I have an assignment in a beginner's compsci class where we have to write a program that asks the user to enter a word, and then the program will repeat the word for as many times as it has characters.

I know I need to use length (x) to get the number of times, but how do I get it to loop x times? Or how do I use a statement such as for i : 1 .. length(x) to output a string instead of numbers?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Feb 19, 2015 1:26 pm   Post subject: Re: How do I get turing to repeat a string a certain amount of times?

gayden @ Thu Feb 19, 2015 10:41 am wrote:
how do I use a statement such as for i : 1 .. length(x) to output a string instead of numbers?

Sounds like you are already familiar with all the required pieces, and just need to give it a try. How do you output numbers that you've mentioned above?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
gayden




PostPosted: Fri Feb 20, 2015 12:17 am   Post subject: Re: How do I get turing to repeat a string a certain amount of times?

Tony @ Thu Feb 19, 2015 1:26 pm wrote:
gayden @ Thu Feb 19, 2015 10:41 am wrote:
how do I use a statement such as for i : 1 .. length(x) to output a string instead of numbers?

Sounds like you are already familiar with all the required pieces, and just need to give it a try. How do you output numbers that you've mentioned above?

I believe I am, but I'm not sure how to actually utilize it.

And what do you mean by that? Like, how do you output a number you mentioned earlier in the program?
(if so, use a variable, get x, put x, etc.)
Insectoid




PostPosted: Fri Feb 20, 2015 2:33 am   Post subject: RE:How do I get turing to repeat a string a certain amount of times?

Everything inside a for loop executes a certain number of times. You've got all the pieces already, you just need to put them together. We really can't give you any more hints without giving away the entire answer.
gayden




PostPosted: Fri Feb 20, 2015 9:48 am   Post subject: Re: RE:How do I get turing to repeat a string a certain amount of times?

Insectoid @ Fri Feb 20, 2015 2:33 am wrote:
Everything inside a for loop executes a certain number of times. You've got all the pieces already, you just need to put them together. We really can't give you any more hints without giving away the entire answer.

I think I've got it, this is what I put:
code:
var word : string
put "Please enter a word: " ..
get word
for i : 1 .. length (word)
    put word
end for
Tony




PostPosted: Fri Feb 20, 2015 1:34 pm   Post subject: RE:How do I get turing to repeat a string a certain amount of times?

Looks good to me.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: