How does an array variable indexing expression differ from an array definition size expression?

How does an array variable indexing expression differ from an array definition size expression?

Recall arrays in C/C++ are 0 based ...

i.e. if 'n' slots ...

first index i is at i = 0

nth index i is at i = n-1

Look at it this way:

int anArray[10];
for (int i = 0; i < 10; i++)
{
    anArray[i] = i+1;
}

So if you print out the array values, they will go from 1 to 10. :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.