I'm need to make a remove function that removes the first occurrence of the passed integer value, if found, and shift each following element to the left and add a zero at the end of the array and then call the remove function from the main function and display the content of the array after the call. This is as far as I've gotten. I really need help on this.
#include <iostream>
usingnamespace std;
int search(int arr[], int size, int val);
int remove (int go[], int s, int v);
constint SIZE =25;
int main()
{
int nums[SIZE]; // array declaration
int found;
int n;
//initialize array nums
for (int i = 0; i < SIZE; i++)
{
nums[i] = rand( ) % 251;
}
// display the content of array nums
cout << "\n************************\n";
for (int i = 0; i < SIZE; i++)
{
cout << nums[i] << "\t";
}
cout << "\n************************\n";
cout << "please enter a number between 0 to 250" << endl;
cin >> n;
found = search(nums, SIZE, n);
found = remove(nums, SIZE, n);
if (found != -1){
cout << n << " was found in our data set!\n";
}
else
cout << n << " was NOT found in our data set!\n";
return 0;
}
int search (int arr[], int size, int val)
{
for (int i = 0; i < SIZE; i++)
{
if (arr[i] == val)
return i;
}
return -1;
}
int remove (int go[], int s, int v)
{
for (int i = 0; i < s; i++)
{
//purposely not completed
}
}