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

Username:   Password: 
 RegisterRegister   
 How to make a for loop inside a for loop?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
enchanted_bloom




PostPosted: Tue Mar 03, 2009 7:20 pm   Post subject: How to make a for loop inside a for loop?

As I said, a line is already a for loop,how can I put this loop inside a for loop...I've seperated the two loops,but I don't get how I can put one inside of the other one.
One of the loop is like this
code:
for counter1:1..5
     put num," "..
end for

The other one is like this..
code:
for counter:1..12
     put " ":12,counter
end for

how can I make the first loop repeat by using the second loop format..
Thanks
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Mar 03, 2009 7:27 pm   Post subject: RE:How to make a for loop inside a for loop?

do you know how a for-loop works? Describe it in words.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
enchanted_bloom




PostPosted: Tue Mar 03, 2009 7:36 pm   Post subject: RE:How to make a for loop inside a for loop?

The loop will countinue each time adding up the numbers until the number previously declared..
I think..i'm not sure...
Tony




PostPosted: Tue Mar 03, 2009 7:40 pm   Post subject: RE:How to make a for loop inside a for loop?

read the documentation -- http://compsci.ca/holtsoft/doc/for.html

then tell me what is meant by statementsAndDeclarations
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
enchanted_bloom




PostPosted: Tue Mar 03, 2009 7:52 pm   Post subject: RE:How to make a for loop inside a for loop?

It basically is a execution that keeps on repeating according to the number of times it was declared,each time adding one to the time repeated.It will stop until it has reached the last value declared.
IS it?
Tony




PostPosted: Tue Mar 03, 2009 7:58 pm   Post subject: RE:How to make a for loop inside a for loop?

yes. Now, what kind of statements can you put in it's place?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
enchanted_bloom




PostPosted: Tue Mar 03, 2009 8:15 pm   Post subject: RE:How to make a for loop inside a for loop?

I think you can put anything...
Tony




PostPosted: Tue Mar 03, 2009 8:19 pm   Post subject: RE:How to make a for loop inside a for loop?

well... as the name implies: statements And Declarations.

another for-loop happens to be a statement (as is said in top-right corner of the documentation page)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
enchanted_bloom




PostPosted: Tue Mar 03, 2009 8:30 pm   Post subject: Re: How to make a for loop inside a for loop?

uh.huh..i get that part..but if I do it like this
code:
for counter:1..12
    for counter1:1..5
        put num," "..
    end for
end for


it doesnt work
Tony




PostPosted: Tue Mar 03, 2009 8:32 pm   Post subject: RE:How to make a for loop inside a for loop?

why not? I get a compile error for that piece of code; what does it say?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BigBear




PostPosted: Tue Mar 03, 2009 8:32 pm   Post subject: RE:How to make a for loop inside a for loop?

That will start the first for loop then enter the second and stay in the second untill it is done then restart the first one which will go into the second etc.
enchanted_bloom




PostPosted: Tue Mar 03, 2009 8:41 pm   Post subject: RE:How to make a for loop inside a for loop?

when it comes out it's a bunch of letters crampled together when i wanted them to be in seperate lines..
Tony




PostPosted: Tue Mar 03, 2009 8:43 pm   Post subject: RE:How to make a for loop inside a for loop?

what does .. do in
code:

put "text"..
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
enchanted_bloom




PostPosted: Tue Mar 03, 2009 8:45 pm   Post subject: RE:How to make a for loop inside a for loop?

oh..it makes the second loop continue on the same line making it look like this
X X X X X
if i didn't do that it will look like this
X
X
X
X
X
Tony




PostPosted: Tue Mar 03, 2009 8:56 pm   Post subject: RE:How to make a for loop inside a for loop?

does this solve your problem?
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: