Saturday, 13 April 2013

deletion in an array list

/*C++  Program for deletion of element from an array
   By sanjay kumar singh,ggsestc*/


#include<iostream.h>
#include<conio.h>
#define size 15
void main()
{
         int ar[size],n,i,val,loc;
         cout<<"\t\tDeletion From Array List At Specified location\n\n";
         cout<<"Enter the no of elements : ";
         cin>>n;
         cout<<"Enter elements of the array :\n ";
         for(i=0;i<=n-1;i++)
         cin>>ar[i];
         cout<<"Entered elements are : \n";
         for(i=0;i<=n-1;i++)
         cout<<ar[i]<<"\t";
         cout<<"\nEnter the location in array list for deletion : \n" ;
         cin>>loc;
         for(i=loc-1;i<=n-1;i++)
         ar[i]=ar[i+1];
         cout<<"Updated array is : \n";
         for(i=0;i<n-1;i++)
         cout<<ar[i]<<"\t";
         getch();
}

No comments:

Post a Comment