PACIFIC SCHOOL OF
ENGINEERING
SUBMITED BY
KISHAN GODHANI SUB-
131120131014
JAYKISHAN DOBARIYA ARRAY
131120131010
NITIN CHAUHAN
131120131006
VRAJTUL BHANDERI Guided
131120131004 by .
SHENIL GAJERA PROF.
131120131013 SHAKUNTALA
ANKIT THUMMAR REVANI
131120131056
INTRODUCTION
Array is a collection of elements
All elements are of the same type
All elements are stored using contiguous memory.
For example,
DECLARATION :-
Int a[5],declares an integer array of five elements.
Elements of an array can be initialised at the time of
declaration.
INITIALIZATION:-
It’s also possible to initialize individual elements as follows :
a[0]=1;
A particular value is accessed writing a number called index
number or subscript in brackets
After the array name. for example,
a[3] is represent third element array.
In array element a[i] can be manipulate like a normal variable.
a[5]=0;
a[5]=a[4]+2
OPREATION WITH ARRAY
Some of the frequently used operation wth array are listed
below
1.Input
2.Output
3.Copy
4.Delete
5.Insert
6.Search
7.sort
8.Merging of sorting arrays
DELETATION
Deletation involves deleting the specified
element from the array.
W A P TO DELETE THE ELEMENT OF ARRAY.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],i,p,n;
clrscr();
printf("\n how many element u enter: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
}
printf("\n Enter position : ");
scanf("%d",&p);
for(i=p;i<=n-1;i++)
{
a[i]=a[i+1];
}
n--;
for(i=0;i<n;i++)
{
printf("\n %d",a[i]);
}
getch();
OUTPUT
How many number you enter:- 4
1
2
54
65
Enter the position:-2
1
2
65
INSERTION
This operation can be used to insert an arbitary
element at specified location in an array.
W.A.P TO INSERT ELEMENTS IN ARRAY
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],i,n,p,x;
clrscr();
printf("\n how many element you enter : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n Enter the position : ");
scanf("%d",&p);
printf("\n Enter new value : ");
scanf("%d",&x);
for(i=n-1;i>=p;i--)
{
a[i+1]=a[i];
}
a[p]=x;
n++;
for(i=0;i<n;i++)
{
printf("\n %d",a[i]);
}
OUTPUT
How many elements you enter:- 4
1
2
54
65
Enter the position:-2
Enter the new value:- 3
1
2
3
54
65
SEARCHING
A searching is a method of locating a specific item of
information in a larger collection of data.
For example…
Program to search for an elements in an array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[30],x,n,i;
/*
a-for sorting of data
b-elements to be searched
n-no of elements in the array
i-scanning of array
*/
printf("\n Enter no of elements:");
scanf("%d",&n);
printf("\n Enter the values: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("eneter the elements to be searched");
scanf("%d",&x);
i=0;
if(i<n)
printf("Found at the location =%d",i+1);
else
printf("\n not found);
getch();
}
OUTPUT:
Enter no of elements : 3
Enter the values: 55 56 57
Enter the elements to be searched : 56
Found at the Location =2
SORTING
REVERSING ARRAY
A process of sort elements in reverse order in
array is called Reversing an Array.
PROGRAM OR REVARSING ARRAY
Void main()
{
int a[100],n,i,j;
For(I from 0 to n-1)
read a[i]
// position I on the first element and
// j on the last elememt
J=0;
J=n-1;
While(i<j)
{
Interchang a[i] and a[j]
i=i+1;
J=j-1;
}
//print the result
For(I from 0 to n-1)
print a[i];
}
ADVANTAGES OF ARRAY
Easy to use
Simple to define
Constant access time
Mapping by compiler
LIMITATION OF ARRAY
It is difficult to define size of array while
writing code .
Inserting and delete is time consuming
It can not provide reuseability
It required to contiguous memory