
-----------------------------------
lei4848
Fri Jun 09, 2006 10:22 pm

difficulties understanding this loop.
-----------------------------------
for j : 1 .. 3
	for k : 1 .. j
		put "*" ..
	end for
end for

I have difficulties figuring out the output of this program.  Please explain how you can solve this program.

-----------------------------------
bluedevils_77
Fri Jun 09, 2006 10:34 pm


-----------------------------------
it just means when j is 1.. then k will only go from 1 to 1.. making 1 star..  when j is 2  the k for will be thru twice.. amking 2 stars.. and when j is 3 the k for will go thru three times.. amking 3 stars..     u could of just done a 

for i : 1..6
put "*"
end for

-----------------------------------
Delos
Fri Jun 09, 2006 10:45 pm


-----------------------------------
it just means when j is 1.. then k will only go from 1 to 1.. making 1 star..  when j is 2  the k for will be thru twice.. amking 2 stars.. and when j is 3 the k for will go thru three times.. amking 3 stars..     u could of just done a 

for i : 1..6
put "*"
end for

Not quite.  Notice that the put statement includes a '..', which means that a new line is not created.  Hence, you should have the following pattern:

*
**
***

Otherwise your explanation is quite correct.

-----------------------------------
TheOneTrueGod
Sat Jun 10, 2006 9:25 am


-----------------------------------
theres no "put "" " so it'll all be on one line, but this question was posted twice, and its obviously a HW / Exam question....
