C++ Functions/Arrays

I'm having issues with this homework problem. Can someone assist? I've started it out I just need a hint or help

The remove function must remove 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 then call the remove function from the main function and display the content of the array after the call.

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
#include <iostream> 
using namespace std; 
int search(int arr[], int size, int val); 
bool remove(int take[], int s, int v);
const int 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); 
 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 nums[], int SIZE, int n)
{
	for (int i = 0; i < SIZE; i++)
	{
		if (nums[i] == n)
			return i;
	}
return -1;
}

Last edited on
Topic archived. No new replies allowed.