-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.cpp
More file actions
58 lines (39 loc) · 711 Bytes
/
Copy pathdelete.cpp
File metadata and controls
58 lines (39 loc) · 711 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
using namespace std;
int main()
{
int n;
int arr1[10];
cout<<"enter n:"<<" ";
cin>>n;
for(int i=0;i<n;i++)
{
cin>>arr1[i];
}
//print array
cout<<" entered array"<<"="<<" ";
for(int i=0;i<n;i++)
{
cout<<arr1[i]<<" ";
}
/*//taking value and position from user
int value;
cout<<"enter value you insert to :"<<" ";
cin>>value;
*/
int pos;
cout<<"entered position to delete:(0-"<<n<<"):"<<" ";
cin>>pos;
//delete
for(int i=pos;i<n;i++)
{
arr1[i]=arr1[i+1];
}
//arr1[pos]=value;//fixed
n--;//fixed
for(int i=0;i<n;i++)
{
cout<<arr1[i]<<endl;
}
return 0;
}