C++ Arrays

Arrays is a collection of same data type. it also define continuous memory location of the variable and which can be reference by the single variable.

Example :-

type variable_name[ ];

Here type specifies data type, Examples of some basic data type.
int a[10];
float a[20];
double a[20];
char a[20];

How , we do Initialization of C++ Arrays :- 

int a[5]={8,56,34.57.78};

int a[ ]= {3,5,6,8,9,12,23};

float a[ ]={13.5,23.7,45.12,-34.4,-12.8};

char a1[7]=”Sumit”;

Example :

int a[6]={3,7,8,12,34,45};All array element would be present in contiguous memory Locations.

  1. All array element would be present in contiguous memory Locations.
  2. 4 byte for the integer variable, total 24 bytes will be occupied by the a variable.
  3. Arrays indexing always start from a[0] .
  4. For the , above example array occupies indexing from a[0] to a[5].

 




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top