Delete an Element from Array in C++

Advertisements

Insert Element in C++ Even Odd Elements Array in C++

C++ Program to Delete an element from Array

Delete an element in an array from specific position


#include<iostream.h>
#include<conio.h>

void main()
  {
   int i,a[5],no,pos;
   clrscr();
   cout<<"Enter Data in Array: ";
   for(i=0;i<5;i++)
   {
    cin>>a[i];
   }
   cout<<"\n\nStored Data in Array:  ";
   for(i=0;i<5;i++)
   {
    cout<<a[i];
   }
   cout<<"\n\nEnter poss. of Element to Delete: ";
   cin>>pos;
   if(pos>5)
   {
   cout<<"\n\nThis value is out of range: ";
   }
   else
   {
   --pos;
   for(i=pos;i<=4;i++)
   {
    a[i]=a[i+1];
   }
   cout<<"\n\nNew Data in Array: ";
   for(i=0;i<4;i++)
   {
    cout<<a[i];
  }
  }
   getch();
 }
 

Output

Enter Data in Array: 10 20 30 40 50
Stored Data in Array: 10 20 30 40 50
Enter poss. of Element to Delete: 2
New data in Array: 10 20 40 50
deleted elements from array
Insert Element in C++ Even Odd Elements Array in C++

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements