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

Program to illustrate the concept of templates.

To create an html file to implement the concept of margin, padding using cascading style sheets.

To configure the IP address for a computer connected to LAN