-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelNumArr.cpp
More file actions
40 lines (36 loc) · 815 Bytes
/
Copy pathDelNumArr.cpp
File metadata and controls
40 lines (36 loc) · 815 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
#include <iostream>
using namespace std;
void deleteNumber(int arr[], int &arraySize, int value )
{
int newSize = 0;
for(int i = 0; i < arraySize; i++)
{
if(arr[i] != value)
{
arr[newSize] = arr[i];
newSize++;
}
}
arraySize = newSize;
}
void printArray(int arr[], int arraySize)
{
for(int i = 0; i < arraySize; i++)
{
cout << arr[i] << endl;
}
}
int main()
{
int numbers[] = {9,7,4,1,4,8,0,10};
int size = sizeof(numbers) / sizeof(numbers[0]);
cout << "Array:" << endl;
printArray(numbers,size);
int delNum;
cout << "Enter the number you want to delete: ";
cin >> delNum;
deleteNumber(numbers,size,delNum);
cout << "The new Array:" << endl;
printArray(numbers, size);
return 0;
}