It can be perplexing for students to begin counting at 0 when they enter a CS class. I made it a point over and over to talk about "Day 0" and "Week 0" in the opening days and weeks just to build familiarity with the idea. Even so, I sought when explaining this idea to ground it in some real-life/non-CS example where we as humans use 0-indexing naturally and possibly without knowing it.

Question: where can we find 0-indexing outside of CS and grounded in everyday human experience?

I'll share the one example I can think of below (Q&A style), but I'd love to hear more, potentially better, examples.

[Note: This question relates to another I just posed.]

  • 11
    The index of an array is a measure of the distance from the start. (not what you asked for, but another way to explain it). – ctrl-alt-delor May 27 '17 at 10:12
  • 2
    There are a few here: en.wikipedia.org/wiki/Zero-based_numbering – ctrl-alt-delor May 27 '17 at 10:32
  • 4
    When playing board games, my six year old starts counting from zero, for the square her counter is on. – Miles May 27 '17 at 19:13
  • 4
    One is the first natural number, but nought is the zeroth. – Miles May 29 '17 at 18:41
  • 7
    As seen by the majority of the comments, the key is to separate index from count. index relates to distance or movement, which has zero as the beginning, while count relates to quantity, which has a (possibly) natural beginning of one. If the students have the proper level of mathematics, you can also use the powers-of-10 (the first, lowest, digit is x*10^0. – Gypsy Spellweaver May 30 '17 at 13:44

13 Answers 13

Ages in the United States (it's not the same around the world).

For the first year of life, children are 0 years old. Only after completion of a year is the age changed to 1. By this logic, a child in his/her second year of life is 1 just as the second element of an array is found at index 1.

Edit: another example is the counting of centuries. An event occurring in the 100s would be in the second century.

Edit #2: watching the Champions League Final, I just thought of another: the timing of soccer. A goal scored during the 20th minute is scored while 19:xx is on the clock.

  • 8
    I thing this answer is exactly it. Just like a ruler, and @Choirbean's string answer: we measure from 0, but (usually) count from 1. In arrays we are giving the distance, a measure. – ctrl-alt-delor May 27 '17 at 11:22
  • 5
    I really like the idea of thinking of the index not as a count per se but as a measurement from the origin. – Peter May 27 '17 at 18:46

You can get at this concept very intuitively in strings before you ever get to arrays. Take a string like "hello world" and ask them a subtle-sounding point: does the string begin here: "*hello world", or here: "h*ello world". They'll certainly be able to identify the correct answer.

Then ask, "how far from the start of the string do we have to go to get to the 'h'? Answer in a number of characters. Do we have to move 5 characters away? 3? 1?" Again, they should be able to identify 0.

Now, it's time for the big reveal. (My description here is in Java)

"When I want to get at that first character, h, I do it with myString.charAt(0). Given what we just discussed, why do you think I would use 0, and not 1?"

At this point, they will naturally move to the idea that it is at the beginning, and that we have moved no steps from the beginning.

"Excellent. This is an example of an index value. And, in Java, when we do index values, we don't count from '1', we actually count the DISTANCE from the start. So, if we want the first character, we move no distance. And how far do we move to get the 3rd character? ..."

When you later get to arrays, you can remind them of the concept, and just say that it is being used again here.

  • 5
    I like this. You can get more real-life examples based on counting the DISTANCE. e.g. If you knock on the first door in an apartment block and ask where Alice lives, they say 'go down 3 doors', that's like indexing into the array of apartments. And if Alice lives in the first then you don't move, ie you go down 0 doors. – Rory May 27 '17 at 21:26

An analogy that will work well in Europe, but not in North America:

Lift Control Panel

Image licensed under the CC BY-SA 3.0 by Bidgee of Wikimedia Commons.

Floors (in European countries) are typically numbered with 0 (or G) as the ground floor, then 1 as the first floor above ground, etc. This could easily be compared to a list/array of floors, with floors[0] being ground, floors[1] being the first floor, and so on.

Note that this analogy won't work particularly well in North American countries, as their convention is to number the ground floor as 1. Nevertheless, the visual element of a building and lift numbered from zero could serve as an intriguing example to illustrate zero-based indexing.

  • 1
    The problem with this is, that, while they are numbered 0, 1, and so on, the floor with number one is also called the first floor (at least in Germany and other European countries I know of), while in an array the first element is not indexed with 1. – Raimund Krämer Jun 6 at 14:29
  • @RaimundKrämer well, that's a defect of the way we talk about arrays, probably stemming back to Fortran days. I avoid using erstes, zweites etc. to refer to array elements, and say instead Startelement and Nachfolgerelement. In English, I use list terminology: the head and the head of tail. (Naming more than the frontmost two, the last, or the middle elements is seldom necessary.) – leftaroundabout Sep 3 at 10:56

The clock (24 hours system)

If we look at the clock, we have to examples of counting hours. The 24 hour system is 0 based. The 12 hour system is interesting, neither 0 or 1 based.

The 12-hour clock

In the 12-hour clock system we start at 12 and make our way up to 11.

This needs some explanation. The 12 hour clock has a funny way of counting, that you may not have noticed. It goes 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. (look carefully at a clock that has AM and PM indicators. Without these, then it is just a regular circular (mod 12) counting system.) 12am, 1am, 2am, 3am, 4am, 5am, 6am, 7am, 8am, 9am, 10am, 11am 12pm, 1pm, 2pm, 3pm, 4pm, 5pm, 6pm, 7pm, 8pm, 9pm, 10pm, 11pm

The 24-hour clock:

In the 24-hour clock things are simpler. Numbers just go up, until we get to the end of the day (mod 24). However we start with zero, this may be to keep it backward compatible with the 12-hour system.

$00\colon{}00\colon{}00$ → $23\colon{}59\colon{}59.99\dot9$


Note I have finally found an advantage of daylight shifting time. In the summer noon is at 13:00, and midnight at 1-oclock. This makes the 12hour system 1 based: 1, 2, 3 … 11, 12; (instead of 12, 1, 2, 3). However AM and PM are now wrong, as the meridian does not move.

  • 3
    I think the idea is that the first hour of the day in the 24-hour clock is 00:00. Hence, what would be 12:01 am is in fact 00:01. See militarytimechart.com – Peter May 27 '17 at 18:55
  • 2
    So what does the phrase "The Eleventh Hour" mean, 10 am? Big deal. Still have more than 13 hours to go. – user737 Jun 15 '17 at 19:33
  • 1
    @nocomprende strangely the 11th hour meant from 11pm. So the 12th hour of the afternoon. – ctrl-alt-delor Jun 15 '17 at 21:36
  • 2
    @nocomprende I just realised that the 11hour is like an octave. An octave is named because depending how you count there is ether 7 or 12 notes in an octave. The 2 biggest cases of error are, null references, not validating inputs, and out by one errors. – ctrl-alt-delor Aug 23 '17 at 14:00
  • 1
    Also, a 'third' in music is the 3rd note in the scale, not three up from the first note. A fifth, seventh, etc - same thing. Octave is thus: 8 notes up, or the entire scale starting over again. The hours of the day used to be noted from sunrise, so there were only about 12 (near the equator). Hours at night were not noted, because no one could see the sundial. "Ship's Bells" start at noon / midnight with a single ring and add one at the half hour. They start over after 8 rings, thus 4, 8 and so on. – user737 Aug 23 '17 at 14:35

I don't see anything confusing in 0-based indexing. In fact, it seems that 0-based indexing is not less natural for humans than 1-based indexing. Humans use 1-based indexing just because of following some long-standing, but weird tradition.

I remember that when I was a pre-school child (<7 years old) and has not been yet influenced by social traditions of numbering (I didn't visit a kindergarten), I used a mixed numbering scheme. For example, when we had in our house a lot of guests sitting around a table, and I was crawling under the table, plotting some childish prank — and I needed to make an association between torsos (I see above the table when I'm out of under-the-table area) and pairs of legs (I see when I'm under the table); I don't remember what prank I was planning, but I strongly remember that to remember a position of a victim-guest, I used scheme like "three+one":
"three+one" numbering (picture based on "Break" by Llisole (cc))
I.e. neither referring this guest as third, nor referring him as fourth was not enough intuitive for me. Indeed: "three" is a number of guests before him — not his position; "four" is a number of guests including him — not his position; probably, if I knew fractional numbers at that time, I'd referred him as "3½-th", but I didn't.
I remembered this episode well, because when I was running to another room to take equipment needed for prank, muttering "three plus one" to myself aloud (not to forget it), the same age girl who was one of guests shouted "four" — which annoyed me very much ("f@#k, I know how to add much larger numbers, but '3+1' is a position specification rather than just sum").

0-based stuff is preferrable everywhere, where gauges are used. You start time from zero (you say "0 hours" at midnight, not "1 hour"; "0 minutes" when a new hour starts, not "1 minute"; "0 seconds" when a new minute starts, not "1 second"), temperature from zero, distance from zero, etc. What really confuses is actual discrepancy between 0-based and 1-based, not the 0-based itself; for example, I needed some time at school to realize why people usually call it "<N+1>-th second" ("minute", "hour", etc) when it's still "0:00:<N>" on stopwatch:
Time scale: time range from 0:00:<N> to 0:00:<N+1> is usually called as <N+1>-th second
IMHO: Nothing would break if some day people will finally switch to 0-based indexing; even vice versa, it would become much more intuitive and comfortable — a stopwatch shows "0:00:<N>", so let's call it "<N>-th second" (not "<N+1>-th"); but some-why people had chosen this weird way of 1-based indexing long ago.

TL;DR: In 0-based indexing we count items before (up to, but excluding) current; in 1-based indexing we count items through (up to and including) current. Neither way is in fact intuitive (for a child that has free choice). Both ways need to be learned.

  • 3
    When I was a child, I thought that adding past 10 required adding two: one to change the 9 to a zero and one more to put the one in front. It took a while for a tutor to figure out why all my sums were off by one. – user737 Jun 15 '17 at 19:39

Exponents representing the values of the digits in positional number systems.

e.g. the-arabic-system / denary / the-system-you-learnt-in-primary-school.

10³  10² 10¹ 10⁰
1000 100 10  1

or binary

2³ 2² 2¹ 2⁰
8  4  2  1

The binary example in binary

10¹¹ 10¹⁰ 10¹ 10⁰
1000 100  10  1

This was @GypsySpellweaver idea, see comment.

  • 1
    Same for polynomials: p(x) = a₀ x⁰ + a₁ x¹ + a₂ x² + … + aₙ xⁿ. – Sasha May 6 at 6:30

For anyone old enough (>30years):

In the UK a few years back we had only a few TV channels, first 1, then 2, they slowly increased to 5: BBC1, BBC2, ITV, channel 4, and eventually channel 5 The TVs typically had 10 numbered slots (sometimes 8). the slots where 0 - 9, we would but the channels into the slots 1 = BBC1, 2 = BBC2, 3 = ITV, 4 = channel-4, 5 = channel-5. So where to but the video recorder ( a device to record TV shows for later viewing). Well if we use slot 6 and the TV companies finally add a 6th channel, then we will have to move it, so we put it in slot zero.


Eventually we suddenly got a load more, with digital TV (Freeview). This story ignores, payed for channels (satellite and cable).

  • 2
    The US had a channel 1 at some point but it was repurposed very early on. TV channels started at 2. Zero was right out. – user737 Jun 15 '17 at 19:40

An example from thermodynamics: the study of heat and temperature.

In thermodynamics there are 4 laws, numbered from zero. Look to see when your pupils study this in physics (science). You now have cross curricular linking, which is also good.

Like Asimov's 0th law of robotics, the zeroth low of thermodynamics was added after the other 3: “The zeroth law was not initially recognized as a law, as its basis in thermodynamical equilibrium was implied in the other laws. The first, second, and third laws had been explicitly stated prior and found common acceptance in the physics community. Once the importance of the zeroth law for the definition of temperature was realized, it was impracticable to renumber the other laws, hence it was numbered the zeroth law.” — https://en.wikipedia.org/wiki/Thermodynamics#Laws_of_thermodynamics

  • Zeroth law of thermodynamics: If two systems are in thermal equilibrium with a third system, they are in thermal equilibrium with each other. This law helps define the notion of temperature.

  • First law of thermodynamics: When energy passes, as work, as heat, or with matter, into or out from a system, the system's internal energy changes in accord with the law of conservation of energy. Equivalently, perpetual motion machines of the first kind are impossible.

  • Second law of thermodynamics: In a natural thermodynamic process, the sum of the entropies of the interacting thermodynamic systems increases. Equivalently, perpetual motion machines of the second kind are impossible.

  • Third law of thermodynamics: The entropy of a system approaches a constant value as the temperature approaches absolute zero. With the exception of non-crystalline solids (glasses) the entropy of a system at absolute zero is typically close to zero, and is equal to the logarithm of the product of the quantum ground states.

Extract from https://en.wikipedia.org/wiki/Laws_of_thermodynamics Text is available under the Creative Commons Attribution-ShareAlike License

  • 2
    Similarly, Asimov's Laws start from zero (although chronologically, the zeroth law was added later). – Aurora0001 May 27 '17 at 10:18
  • 1
    @Aurora0001 I added in a bit on asimov. (also I think you should make an answer on asimov) – ctrl-alt-delor Jun 4 '17 at 7:50

This one in related to computing, but sufficiently different, as it related to the social side. You can link it in by teaching the social side before indexing.

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbour (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

Extract from https://www.gnu.org/philosophy/free-sw.en.html (Creative Commons Attribution-NoDerivatives 4.0 International License).

  • 1
    You are missing 5 freedoms. And the fact that a bunch of computing folks used an 0 indexed array as is kinda... expected. OP is looking for non-computing examples, like military time and people's age (as mentioned in other answers/comments) – ivanivan Jan 23 at 14:26
  • 1
    @ivanivan can you tell us about the 5 freedoms, I know not of this. And added answer on 24hour time. – ctrl-alt-delor Jan 23 at 17:01
  • 1
    the freedoms you list are from the Free Software Foundation - Stallman and co. However, the Open Source Definition lists other requirements/freedoms needed for a license to be considered Open - opensource.org/osd-annotated. Remember, Stallman insists that all software be free, the Open Source Initiative wants as much as possible to be free, but not at the expense of extremism – ivanivan Jan 23 at 19:57

A common example I use is centuries/years. We start with the first century on a range of 0-100 years. Or the first year of a century, which always ends in 00. It describes the amount of x that has passed, not the n-th x.

The word "first" is the confusing thing for beginners I feel.

  • 3
    There was no your zero, therefore the end of a century ends in 00. 2000 was the last year of the 20th century. Most people get this wrong, the rest of us let it pass for a year, then have a 2nd party. – ctrl-alt-delor Jun 15 '17 at 21:42
  • 4
    I sometimes say "oneth" to avoid the ambiguity of "first". – Ellen Spertus Jul 27 '17 at 23:00
  • 3
    @ctrl-alt-delor actually, it’s the perfect example of what a mess is created when not using index zero. ”Most people get this wrong” by intuitively assuming that a century should start with year zero and end with year 99 and are “wrong”, because there was no year zero. But we still live in the 21st century whose index (year number) starts with a 20 (except for the last one) and the third millennium whose index (year number) starts with a two (except for the last one). And if that one guy was truly born 24.12.1, your 2nd party was wrong as well (otherwise, that number is totally meaningless). – Holger Sep 6 at 11:55
  • 1
    @ctrl-alt-delor: You are correct. However, this 0-based system is actually used to express the age of a person, and people are not known to struggle with that. The difference is that when you're at "age 0", we omit the year count altogether: "He is 3 months old", not "He is 0 years and 3 months old". When you 0-index, and you're at index 0, that often entails deferring to a more precise (non-0) measurement. – Flater Sep 18 at 6:33
  • 1
    @Flater yes you bring up an interesting point. In Europe and US, we measure age, so 3 years old, means that you are between 3 and 4 years old, that is have been alive 3 years, but no more than 4 (Well maybe an extra ¾ day, see leap year). In some parts of the world, they say what year you are in. Therefore a new born is 1, (in 1st year). This is similar to school year, before we added year zero (K in US, R in UK). In any respect the systems are all self consistent. but can result in an out by one error if the 2 people communicating are using a different system. – ctrl-alt-delor Sep 18 at 7:11

Light gang switches, same the way you teach binary counting. (Well, the same way that I was taught binary arithmetic back when knowing binary and hex were important.)

EDIT: An off transistor (simulated by a light switch) is considered to be 0 (no voltage) and an on to be 1 (voltage passing). Since "all zeros" is a valid configuration, 0 is a valid address where Important Bits can reside. That's why many languages base arrays using 0.

EDIT 2: It's also the basis of pointer arithmetic. Your array has a base address at location A, so that's where the first element goes. When you're referencing the elements in a loop, you add an offset O to get to each array element. To access the first element, the value of O must be 0.

enter image description here

  • 1
    @Buffy sorry. I assumed that CS Educators all know the light-switch analogy. – RonJohn Jan 15 at 14:33
  • 1
    @Buffy ok. I added (a hopefully clear) explanation. – RonJohn Jan 15 at 14:38
  • 2
    @Buffy interesting. This was Standard Knowledge 35 years ago when students had to learn pointer arithmetic and take at least one class in Assembly. – RonJohn Jan 15 at 14:49
  • 1
    Welcome to CSEducators. Come back often. – Buffy Jan 15 at 14:52
  • 1
    Using 0 and 1 for binary states is unrelated to the mathematical values of 0 and 1. We could instead use "nothing" and "something" and the entire field of logic would remain correct. This is why programming now favors true and false, instead of "a non-zero integer" and "a zero integer". It disambiguates logical evaluations from mathematical ones and prevents developers mistakenly assuming one for the other. – Flater Sep 18 at 6:37

Subtraction paradox: In North-American football, if a runner goes from the 3 yard line to the 4 yard-line, there is a (4-3) = 1 yard gain. However, if your math teacher assigns problems 3-4 (integers), you have to do two problems. So in what engineers call an "analog" system, the Result = Stop - Start; but for integers it can be more complex.

So in North American football, the yard line starts at "0" which is called the "Goal Line" typically.

  • 1
    if a runner goes from the 3 yard line to the 4 yard-line, there is a (4-3) = 1 yard gain. However, if your math teacher assigns problems 3-4 (integers) The core difference here is that the former denotes the distance between points, and the latter denotes the points themselves. 2017 and 2018 are two distinct years (points), but the timespan (distance) between NYE 2017 and NYE 2018 is one year. This does not actually answer why 0-based indexing is used, as you're simply comparing two inherently different things. ("from 3 to 4" vs "3 and 4") – Flater Sep 18 at 6:27
  • One must use 0 as a base, however. – JosephDoggie Sep 18 at 12:15
  • 1
    One must use 0 as a base. I don't quite agree, 0-indexing is not universally superior to 1-indexing. As I mentioned in my earlier comment, it depends on what you're actually expressing (points, the distance between them, ...). There are many cases where the 0th element is a literal "nothing", thus precluding 0 from being relevant (especially when pertaining to physical objects). – Flater Sep 18 at 13:34

UK school years

We used to have years 1,2, 1,2,3,4, 1,2,3,4,5,6th form.

We then changed to 1,2,3,4,5,6,7,8,9,10,11,12,13 (years 12 and 13 are 6th form, no one know where this name comes from).

Then we added reception year, to get R,1,2,3,4,5,6,7,8,9,10,11,12,13.
R is just a different symbol for 0. (In the US K is used for 0.)

  • In the U.S. there would be 'K' and 13 would mean college, 'K' has been around for quite a while -- everything else is the same! – JosephDoggie Sep 14 at 19:55
  • 1
    @JosephDoggie In UK years 12 and 13, can be college, but some(may be most) schools, have a 6th form. This Does the same as the early college years, but at a school. After these 2 years, a lot of pupils go on to university (or work, or more college). – ctrl-alt-delor Sep 15 at 10:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.