array elements

Feb 19, 2012 at 12:08am
So i have been reading about arrays , and they gave me the definition of an array element , but i still can't manage to understand what they are referring to
can someone give me simple example as to what it is .
Feb 19, 2012 at 12:13am
I think of arrays as matricies.
like this:
1
2
3
4
5
6
7
8
9
int x[5] //this makes an array called "x" that holds 5 integers.
//basically it can hold 5 numbers like this:
x[1]=1;
x[2]=2;
x[3]=3;
x[4]=4;
x[5]=5;

//so now the array equals {1,2,3,4,5} 

The array might start at zero and end at 5 or 4. I don't remember.
Feb 19, 2012 at 12:15am
thanks man, but what specific in that code would you call an element?
Feb 19, 2012 at 12:18am
I have never heard that term used before, So I went and checked.
It looks like one 'thing' in the array is an element.
So in that example above: x[1] is an element, x[2] is an element, and so on.
Feb 19, 2012 at 12:19am
wonderful thank you very much.
Feb 19, 2012 at 12:24am
No problem
Feb 19, 2012 at 12:34am
Keep in mind, you can't add two arrays together or anything like that.
Topic archived. No new replies allowed.