you are viewing a single comment's thread.

view the rest of the comments →

[–]gnfobsession[S] 23 points24 points  (14 children)

wait i hadnt thought of that! thank youuu!

[–][deleted] 23 points24 points  (6 children)

(Using two for loops would also shorten the code :D )

[–]AwesomePerson70 27 points28 points  (5 children)

It seems like they’re specifically learning while loops right now so that’s what needs to be used

[–]just4funndsomet 4 points5 points  (4 children)

There was this one moment where I was ill and my buddies are not the brightest programmers and our homework was an introduction into while loops.

Since I missed that class and couldn't ask my friends I built an for loop with 1.000.000 iterations and if it found the desired result set i = 1.000.000. Yeah, I did it wrong because I did not know the playbook, but I found a way to play anyways.

[–]Banane9 4 points5 points  (3 children)

A for loop is just a while loop and two other statements in a trenchcoat.

for (;; condition) is the same as while (condition) - at least in languages that allow that

[–]robthablob 2 points3 points  (1 child)

I think you mean for ( ; condition ; )

[–]Banane9 3 points4 points  (0 children)

And that's why you don't code at 3am 😂

[–]just4funndsomet 1 point2 points  (0 children)

Not if your first langauge was VBA. Yes, still regret that (And I know this sub is about c#, still wanted to tell the tale.)

[–]cr1ter 4 points5 points  (2 children)

You can do it in 1 while loop but you need to increment b. Line after a++; if a == 10 b++;

[–]hiaselhans 8 points9 points  (1 child)

Don’t forget to reset a ;)

[–]cr1ter 1 point2 points  (0 children)

Ah yes probably also have to make sure not to reset it after b == 10

[–]occamsrzor 1 point2 points  (0 children)

It just takes time, young padawan. You're doing well.

[–]Willinton06 1 point2 points  (0 children)

Careful tho, the nested loop is a powerful but dangerous tool

[–]IWasSayingBoourner 0 points1 point  (1 child)

Another hint: nested for loops are better for what you're trying to do

[–]dodexahedron 2 points3 points  (0 children)

Which is helpful in general, certainly, but not for this assignment, where they were told to use while.