-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path9.cpp
More file actions
31 lines (31 loc) · 648 Bytes
/
Copy path9.cpp
File metadata and controls
31 lines (31 loc) · 648 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
// deletion operation at beginning - direct
#include<iostream>
using namespace std;
int main(){
int a[20],i,lb,ub;
cout<<"Enter the lower and upper bounds of array: ";
cin>>lb>>ub;
cout<<"Enter elements:\n";
for(i=lb;i<ub;i++){
cout<<"Element "<<i+1<<": ";
cin>>a[i];
}
cout<<"Array:\n";
cout<<"[";
for(i=lb;i<ub;i++){
cout<<" "<<a[i];
}
cout<<"]\n";
// deletion at beginning logic
for(i=lb;i<=ub-1;i++){
a[i] = a[i+1];
}
ub--;
cout<<"\nNew Array:\n";
cout<<"[";
for(i=lb;i<ub;i++){
cout<<" "<<a[i];
}
cout<<"]";
return 0;
}