Why "C" Programmers May Think The Millenium Begins
in the Year 2000

By Jeff Robinson

There's been a lot of discussion as whether the new millenium begins this year or next year in 2001. Well, the math geeks will tell you that it really doesn't begin until next year. However, someone experienced in "C" programming may be convinced that it actually already began on Jan. 1, 2000. Let's explore the possible reasoning behind this assumption.

The "C" Programming language allows you to declare a variable as a multiple occurring data item using a special notation. When you make such a declaration its called an "array" and the notation must use the open and close square

brackets on your computer keyboard with the number of occurrences between the brackets.

Here's an example of an integer array which declares 10 items:

Example 1.

    int NumofYears[10];

You can now use the new variable, NumofYears, in any statement in which you would normally place a numeric variable in. However, the stipulation is that you must also indicate which occurrence of the array you want use. That's

because the name "NumofYears" no longer refers to one value but rather a group of values. For instance, if you wanted to assign the number 2000 in the first array slot, you would need to indicate it like this:

Example 2.

    NumofYears[0] = 2000;

Take special note that the number between the brackets in Example 2 is a 0 (zero) and not a 1 (one). Unlike other programming languages where the first array item begins with the subscript of 1, "C" uses a zero-based indexing scheme which requires that the first index be indicated with 0. Now, this could be quite disconcerting if you needed to place 10 numbers in the array and you wanted to somehow match the first number with index array "1" for easy remembrance.

Example 3.

    for (i=1; i<=10; i++)
    Numof Years[i] = 2000 + i;

The for loop above actually assigns the first number, 2001, to the second index position at Numof Years[1] not the first index position of NumofYears[0]! Until a value is placed at NumofYears[0], it would be left unassigned and unused. Furthermore, because the last index in the array is actually indexed at NumofYears[9], the last assignment in the for loop would generate an error because it attempts to place a value at NumofYears[10] which is actually the eleventh array index. Quite a conundrum, huh?

To get around this problem, "C" programmers sometimes include that one extra value at the beginning of arrays that's really a throw-away value. In this case, the value for the last year in this millenium, 2000, gets to become the first year stored in our array at index value 0. Now, all we have to remember is that the first year of the next millenium really is in the array position indicated by subscript 1. In our situation, the previous declaration for NumofYears and the for loop assignment could be changed to include the value for the year 2000 in this manner:

Example 4.

    int NumofYears[11];     /*Need to make 11 assignments now */
    for (i=0; i<=10; i++)     /*Change loop to make 11 assignments 2000-2010*/
    Numof Years[i] = 2000 + i;

Thus, we can now understand how a "C" programmer may begin to think that the year 2000 and not 2001 is the first year in the new millenium: "C" is a zero-based language and some value has to go into that index at position 0. Solution: allow the millenium to begin at the year 2000 and our zero-based array will be properly filled!