Arrays

A programmer working on a large project noticed that every single variable was stored in a separately named instance:

int c1, c2, c3, c4, c5, c6;

This meant that there was a lot of code of this sort:

c1++;
c2++;
c3++;
c4++;
c5++;
c6++;

Of course, this can be done more efficiently with a loop, so the programmer suggested it. None of his co-workers understood the concept, so he approached the boss, and showed him some example code, that would do the same thing in a loop:

int c[6], i;
for (i=0; i<sizeof(c);i++) {
  c[i]++;
}

He explained to his boss that this small change was a necessary improvement to the system architecture and skills of the programming team. His boss having once been a programmer understood completely, and asked, “So you want arrays?”

“Yes,” he replied.

On payday there was a substantial increase in his renumeration.

This entry was posted in Stuff and tagged , , , , . Bookmark the permalink.