-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11_deletion.cpp
36 lines (32 loc) · 874 Bytes
/
11_deletion.cpp
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
// Coding deletion operation in Array using C++ language.
#include<iostream>
using namespace std;
void display(int arr[] , int n){
// Code for traversal
for(int i = 0;i<n;i++){
cout<<"Your number at index "<<i<<" is "<<arr[i]<<endl;
}
}
void index_deletion(int array[] , int n , int index , int capacity){
// Code for deletion
if(index>=capacity){
cout<<"You can not do deletion . "<<endl;
}
for(int i=index;i<n-1;i++){
array[i] = array[i+1];
}
}
int main(){
int array[100] = {1,5,67,89,54};
int size = 5;
display(array , size);
int index;
cout<<"Enter the index on which you want deletion . "<<endl;
cin>>index;
int capacity = 100;
index_deletion(array , size , index , capacity);
size -= 1; // size = size - 1;
// cout<<size<<endl;
display(array,size);
return 0;
}