Help URGENT

Write a function called Insert that takes in four parameters:
an integer array
the size of the array
the new value to be inserted into the array
the index at which to insert the new value
This function should insert a a new value into the array, at the specified index. Note that this means that other values have to "move" to make room. The last value in the array will just disappear from the array. If the index is out of bounds for the array, abort the function with no change made to the array. This function does not return a value. Sample call:
// Suppose the array "list" is {2, 4, 6, 8, 10, 12}

Insert(list, 6, 100, 3); // insert the value 100 at index 3.

// "list" is now {2, 4, 6, 100, 8, 10} im confused this is what I have so far

1
2
3
4
5
6
7
8
9
10
11
12
13
  void Insert(int arr[], int SIZE, int newValue, int index)
{
	int i;
	int temp;
	if (index < SIZE);

	while (i < SIZE - 1){
		temp = arr[0];
	// think the for might be better to use
		for (int i = 0; i < SIZE-1; i++);
		temp = arr[0];

	}
Last edited on
before starting to code, write a pseudocode or a diagram flow.
the snip that you've posted does nothing, doesn't even allow to guess what problem you are having.

you may find it easier to work with an auxiliar array.
Topic archived. No new replies allowed.