forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleting.cpp
More file actions
34 lines (33 loc) · 672 Bytes
/
Copy pathdeleting.cpp
File metadata and controls
34 lines (33 loc) · 672 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
#include <iostream>
using namespace std;
int main()
{
int a[10];
int n = 10;
cout << "Input numbers for into arrays." << endl;
for (int i = 0; i < n; i++)
{
cout << "a[" << i << "] = "; // input array
cin >> a[i];
}
int value;
int position;
cout << "Enter value which you want to delete: ";
cin >> value;
for (int i = 0; i < n; i++)
{ // finding the position
if (value == a[i])
position = i;
}
for (int i = position; i < n; i++)
{ // incrementing the array elements into 1
a[i] = a[i + 1];
}
n = n - 1;
for (int i = 0; i < n; i++)
{
cout << "a[" << i << "] =" << a[i] << endl; // output arrays with correct order
}
a[9] = 0;
return 0;
}