xxxxxxxxxx
// remove *all* 3's, return new ending (remaining elements unspecified)
auto arrayEnd = std::remove(std::begin(array), std::end(array), 3);
xxxxxxxxxx
#include<iostream>
using namespace std;
int main()
{
int arr[]={1,2,3,4,5};
int choice;
cout<<"enter a number: ";
cin>>choice;
for(int i=0;i<5;i++)
{
if(choice==arr[i])
{
for(int j=i;j<5;j++)
arr[j]=arr[j+1];
}
}
for(int i=0;i<5-1;i++)
{
cout<<arr[i];
}
return 0;
}
xxxxxxxxxx
#include<iostream>
using namespace std;
int main()
{
int arr[10], tot=10, i, elem, j, found=0;
cout<<"Enter 10 Array Elements: ";
for(i=0; i<tot; i++)
cin>>arr[i];
cout<<"\nEnter Element to Delete: ";
cin>>elem;
for(i=0; i<tot; i++)
{
if(arr[i]==elem)
{
for(j=i; j<(tot-1); j++)
arr[j] = arr[j+1];
found++;
i--;
tot--;
}
}
if(found==0)
cout<<"\nElement doesn't found in the Array!";
else
cout<<"\nElement Deleted Successfully!";
cout<<endl;
return 0;
}