Write a program to delete an element from a given whose value is given or whose position is given

#include<iostream>
using namespace std;
int main()
{
int arr[10],n,i,o,p;
cout<<"Enter the no.of elements to be enter:";
cin>>n;
cout<<"Enter the elements:\n";
for(i=0;i<n;i++){
cin>>arr[i];
}
cout<<"\nArray entered is :";
for(i=0;i<n;i++)
{
cout<<arr[i]<<" ";
}
cout<<"\nEnter the position of element to be deleted:";
       cin>>p;
       for(i=p;i<n;i++)
       arr[i-1]=arr[i];
       n--;  
cout<<"\nThe Array after operation is:";
for(i=0;i<n;i++)
cout<<arr[i]<<" ";
cout<<"\n/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:



Comments

Popular posts from this blog

To create an html page with frames and frameset

1. Write a program to insert a new element at end as well as at a given position in an array in Java

1. To familiarize with network devices like switch, hub, routers and bridges in LaTex