unit 2
unit 2
unit 2
ARRAY
PRESENTED BY
Ms.S.JANANI,DEPT OF CSE,
ASSISTANT PROFESSOR
SYLLABUS
sequential collection of
elements of same data types
that share a common name.
Example where arrays are
used,
to store list of Employee
or Student names,
to store marks of
ARRAY TYPES
Singledimensional array
Two dimensional array
multi-dimensional array
is,
data-type variable-name[size];
/* Example of array declaration */
int arr[10];
DECLARING AN SINGLE
DIMENSIONAL ARRAY (CONT…)
#include<stdio.h>
void main()
{
int arr[4],i, j;
CONT…
printf("Enter array element");
for(i = 0; i < 4; i++)
{
scanf("%d", &arr[i]); //Run time array
initialization
}
for(j = 0; j < 4; j++)
{
printf("%d\n", arr[j]); //traversal
}
}
Accessing elements operations
Accessing elements in an
single dimensional array
Traversal
Insertion
Deletion
Searching
INSERTION
Input the array elements, the
position of the new element to
be inserted and the new
element.
Insert the new element at that