Page 96 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 96
Unit 6: Operations on Arrays and Sparse Matrices
scanf("%d",&a[i]); Notes
clrscr();
printf("nOriginal array is : ");
for(i=0;i<n;i++)
printf(" %d",a[i]);
printf("nUpdated array is : ");
for(i=0;i<n;i++)
{
for(j=i+1;j<n;)
{
if(a[j]==a[i])
{
for(k=j;k<n;k++)
a[k]=a[k+1];
n--;
}
else
j++;
}
}
for(i=0;i<n;i++)
printf("%d ",a[i]);
getch();
}
Output:
Enter array size : 5
Accept Numbers : 1 2 2 3 4
Original array is : 1 2 2 3 4
Updated array is : 1 2 3 4
Question
Write a program to retrieve an element from an array.
Source: http://www.c4learn.com/c-programs/to-delete-duplicate-elements-in-array.html
6.3 Summary
Operations on arrays include Creating an array initializing an array, inserting an element,
deleting an element, merging arrays, etc.
A sparse matrix is a matrix that allows special techniques to take advantage of the large
number of zero elements.
A triangular matrix is a square matrix in which all the elements either above or below the
main diagonal are zero. Triangular matrices are sparse matrices.
LOVELY PROFESSIONAL UNIVERSITY 89