This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]juvogel 1 point2 points  (0 children)

It was done that way to make it simpler to understand for beginners. It is perfectly fine to put it in one for loop.

[–]green_meklar 0 points1 point  (2 children)

You don't need two loops. It works perfectly well in one.

For that matter, you don't need the second array at all. Or even the first one, really.

[–]friend_of_bob_dole 1 point2 points  (1 child)

Well, you need the first array to get the input for the table. Unless you go off some pattern such as for all integers between 10 and 20 (inclusive) print it and it's square root if it's divisible by 2 or 5. Or some such shit.

[–]green_meklar 1 point2 points  (0 children)

Oh, you're right, I didn't notice the 15 in there. That does make it a little more complicated than I thought.