The subscript of an array can be ' an expression ' which yields integers. Note that any reference to the array outside the declared limit would not necessarily cause an error.
If array size declared as 10 , then we declare first element to zero , as
int array [10] = {10} ;
then all elements are declared as zero automatically.
Here is an example of wrong declaration to an array.
char alpha [3] = {a,b,c} .
If you want to store alphabets into an array store its integer values ,
char alpha [3] = { 'a' , 'b' , 'c' }
and print them as characters.
No comments:
Post a Comment