Introduction to Array

Introduction to Array

An array is collection of same data type of elements that refer by a common name. An array is a liner data-structure which store the all elements in a sequence.

Property of Array:

  • Array require a contiguous memory space to store elements
  • The size of an array must be define at the declaration time
  • The array elements are accessed by its index number.
  • An array index must be start with 0 so the last index is size_of_array-1

Terminologies

  • Element — Each item stored in an array is called an element.
  • Index — Each memory location of an element in an array is identified by a numerical index.

Declaration of Array:

Syntax:

<Data Type> <Array Name>[size];

Example:

int num[20];

  • Data Type: Data type of element you want to store in an array.
  • Name: Name of the array.
  • Size: Length of the array i.e. how many elements you want to store.

Basic Operations

There are some specific operations that can be performed or those that are supported by the array. These are:

  • Traversal: To traverse all the array elements one after another.
  • Insertion: To add an element at the given position.
  • Deletion: To delete an element at the given position.
  • Searching: To search an element(s) using the given index or by value.
  • Updating: To update an element at the given index.
  • Sorting: To arrange elements in the array in a specific order.
  • Merging: To merge two arrays into one.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz