-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdel.cpp
More file actions
28 lines (26 loc) · 694 Bytes
/
Copy pathdel.cpp
File metadata and controls
28 lines (26 loc) · 694 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
//Deletion Operation
#include <iostream>
#include <conio.h>
using namespace std;
int main(){
int arr[10]={10,20,30,40,50};
int n=5;
int i,pos,value;
cout<<"Array Elements are : "<<endl;
for(i=0;i<n;i++){
cout<<"Element at index "<<i<<" is "<<arr[i]<<endl;
}
cout<<"Enter the position where you want to delete an element : ";
cin>>pos;
for(i=pos;i<n;i++){
arr[i]=arr[i+1];
}
value=arr[pos];
n=n-1;
cout<<"Array after Deletion is : "<<endl;
for(i=0;i<n;i++){
cout<<"Element at index "<<i<<" is "<<arr[i]<<endl;
}
cout<<"The total length of an Array is : "<<n;
getch();
}