-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathdeletion.cpp
More file actions
38 lines (36 loc) · 823 Bytes
/
Copy pathdeletion.cpp
File metadata and controls
38 lines (36 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
using namespace std;
int main()
{
int arr[100], n, elem, found=0;
cout<<"Enter the size of Array: "<<endl;
cin>> n;
cout<<"Please enter the array of elements:"<<endl;
for(int i=0; i<n; i++)
cin>>arr[i];
cout<<"Enter Element to Delete: "<<endl;
cin>>elem;
for(int i=0; i<n; i++)
{
if(arr[i]==elem)
{
for(int j=i; j<(n-1); j++)
arr[j] = arr[j+1];
found++;
i--;
n--;
}
}
if(found==0)
cout<<"Element doesn't found in the Array."<<endl;
else
{
cout<<"Element Deleted Successfully."<<endl;
cout<<"The New Array is:"<<endl;
for( int i=0; i<n; i++)
{
cout<<arr[i]<<" ";
}
}
return 0;
}