Array in c++ programming

Array

"Array is a Set of similar datatype variable under a single name."

To declare an array
syntax:-


      Datatype arrayname[size];

To initialization an array


int a[5]={78,45,12,89,56};

Array initialization

Important points about array

  • The address of first element is called base address ab array.
  • Array name represent base address of an array .
      Ex-48252
  • This is a unique no used to access an element in an array is know as base address of array.
  • The index of first element is always zero (0) an array.
  • The index of last element is always one less of array size.
    Size of array= 5.
    Last index of array=5-1=4.
  • The positive of element in a array always once more it's index.
    Index of 45=1.
    Position of 45=2.

Access an element

  1. set value.
  2. get value.

set value

syntax

      int a[2]={10,20};

get value

 syntax 

       int a[2];
      cout<<a[2];

Operation an array

  1. Input.   
  2. Output.  
  3. Searching.  
  4. Sorting. 
  5. Insertion. 
  6. Deletion. 
  7. Merging. 

There are two types of array


  • Single dimensional array
  • Double dimensional array 

Comments

Popular posts from this blog

Function in C++ with example & declaration, initialization function in c++

Operators of c++

Storage class in c++