Array in c

        The data elements in an array are represented in linear manner, i.e., there is linear relationship among the elements and these elements are stored in consecutive memory locations and this is why an array is known as linear data structure. An array may contain all integers or all characters or any other data type, but may not contain a mix of data types.

The general form for declaring a single dimensional array is:

Datatype array_name[Array Size];

 where Datatype represents data type of the array. That is, integer, char, float etc. array_name is the name of array and  Array Size which indicates the number of elements in the array.

EXAMPLE:

char Name[5];           //char type array
int Roll[10];               //int type array
float Mark[20];         //float type array


Array Elements in Memory

  #include<stdio.h>
  #include<conio.h>

  int main()
  {
       float Marks[9] = {56.12, 85.63, 91.32, 82.52, 39.45, 75.56, 45.50, 96.50, 55.36};
       printf("   Array   | Address |  Values");
       printf("\n  ...........................");
       for(int i=0; i<9; i++)
       {
              printf("\n  Marks[%d] | %x  | = %.2f",i,&Marks[i],Marks[i]);
       }
       getch();
       return 0;
  }

Output:


The format of declaration of a multidimensional array in c++ is given below:

   data_type array_name [Array size][[Array size] .......[Array size] ;