this post was submitted on 09 Jul 2023
628 points (94.0% liked)

Programmer Humor

32048 readers
1364 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] -2 points 1 year ago* (last edited 1 year ago) (3 children)

WTF, I have never used nor seen "j."

I don't usually have to name these variables these days though. Pretty much everything I use has foreach or some functional programming type stuff.

And like that, the off-by-one mistakes disappear.

[โ€“] [email protected] 3 points 1 year ago

It was very common in text books when showing nested loops

int nWhatTheCount = 0;
for (int i = 0; i < 10; i++) { 
    for (int j = 0; j < i; j++) { 
        for (int k = 0; k < j; k++) { 
            for (int l = 0; l < k; l++) { // and on, and on
                nWhatTheCount++;
            }
        }
    }
}
load more comments (2 replies)