array 2 hina

Download Array 2 hina

Post on 16-Jul-2015




0 download

Embed Size (px)


PowerPoint Presentation

To presentation

Mohanlal Sukhadia University Udaipur


Prakash KhaireThe Mandvi Education Society Institute of Computer Science


Introduction Need for on array Types of array 1D 2D MDDifference between 1D & 2D ArrayArray Applications Advantages & disadvantages

What is an Array ?

Introduction It is derived data type. The nature of array is static (fix). Array is a collection of similar or homogeneous data type. Array is also known subscript variable or index variable.

The lower bond of an array is zero 0.

The upper bond of an array is n-1. for ex.-int a[9] is an array that stores 9 integers

Array index start with zero(0).Array end with n-1.012345678100102104106108110112114116indexelementsMemory address'

Need for an ArrayNEED FOR AN ARRAYTo store large number of variables of same type under a single variable.E.g.To store Marks of 50 students.Record of sales of 100 salesman.

Types of ArrayOne - Dimensional ArrayTwo - Dimensional ArrayMulti - Dimensional ArrayOne-Dimensional ArrayA list of items can be given one variable name using only one subscript and such a variable is called a one- dimensional Array.Syntaxdata_type ArrayName[size];data_type : is a valid data type like int, float,char

Arrayname : is a valid identifier size : maximum number of elements that can be stored in array Declaration of on ArrayTo declare an array to syntax is- Data_ type variablename [size];

The type of data which you want to store like int , float , char.Means the name of an Array.The number of Array type variable.Ex.- int a [3];Type of array variable is integer. Its variable name is a. 3 is the size of the array.

InitializationAn elements of an array must be initialized, otherwise they may contain garbage value.An array can be initialized at either of the following stagesAt compile timeAt run timeAt the time of declaration and initialization at the same time.For ex.- int a[5]={1,2,3,4,5}An array can be explicitly in initialization at run time.To initialize multiple array variable for loop is used. for ex.- for (i=0;i