c declare array code example

Example 1: create n number of arrray in c

int n,i;

//enter n

int **array = malloc(sizeof(int*)*n);

for(i=0;i<n;i++)
  array[i] = malloc(sizeof(int)*64);

 /* Do Stuffs*/


/* Free Memory */  
for(i=0;i<n;i++)
  free(array[i]);

free(array);

Example 2: array loop in c

int i, array[5]= {1, 2, 3, 4, 5};
for(i=0 ; i<5 ; i++)
{
	printf("%d", array[i]) ;
}

Example 3: how to initialize an array in c

double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};

Example 4: array of array in c

int a[3][4] = {  
   {0, 1, 2, 3} ,   /*  initializers for row indexed by 0 */
   {4, 5, 6, 7} ,   /*  initializers for row indexed by 1 */
   {8, 9, 10, 11}   /*  initializers for row indexed by 2 */
};

Example 5: c language array

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