this declares and initializes a one dimensional array of integers. its name is 'a' int a[]={1,2,3,4,5,6,7,8,9,10;}
this declares an array 'a' of size 10 integers where each element is initialized with value '0' int a[10]={0;}
in both cases a[0] is the first element and a[9] is the last element.
I believe the semicolons go on the right side of the right brackets, not inside them. Also, I don't find that int a[10]={0}; initializes all the elements to zero. I try it with a 1, and only the first element is a 1, the rest are zeroes, unless it only works with a zero.
Some Examples: Declare one dimensional array of integers.
1. Declare a one dimensional array.
Array size specifies # of elements to reserve space for.
The element values are NOT initialized - unless this is a global array [Bad idea] ...
int ar[7] ; // Array Element Values: ?, ?, ?, ?, ?, ?, ?
2. Declare a one dimensional array with a full initializer list.
Array size specifies # of elements to reserve space for.
The element values are loaded with the values from the initializer list.
3. Declare a one dimensional array with a partial initializer list.
Array size specfies # of elements to reserve space for.
The beginning element values are loaded with the values from the initializer list, remaining element values are set to 0
4. Declare a one dimensional array with a initialzer list, omit the explicit array size...
The # of elements in the array is determined by the # of items in the initializer list...
int ar[ ] = { 1, 2, 3 } ; // Array Element Values: 1, 2, 3