Initialization of Array

In c programming, initializing of array is very simple. The initializing values are enclosed within the curly braces in the declaration and placed following an equal sign after the array name. Array can also be initialized after declaration.

int myArray[5] = {1, 2, 3, 4, 5}; 

Declaration of Array

Arrays must be declared before they can be used in the program. Standard array declaration is as

type variable_name[lengthofarray];

Here type specifies the variable type of the element which is going to be stored in the array. In C programmin language we can declare the array of any basic standard type which C language supports. For example

double height[10];  
float width[20];  
int min[9];  
char name[20];

In C Language, arrays starts at position 0. The elements of the array occupy adjacent locations in memory. C Language treats the name of the array as if it were a pointer to the first element This is important in understanding how to do arithmetic with arrays.

The reference site for this content is http://www.mycplus.com/tutorials/c-programming-tutorials/arrays/

Back