I am having trouble working with an array problem, searching and deleting ints.Any help would be very appreciated. Thank you very much!
Goals:
-array of ints with 30 elements
-int to (index +1) * 5 for first 20 elements
-Display result
-add 68, 2, 114, 111
-Display result
-remove 114,42,60,2
-Display result
-use binary search
Questions/Problems
1) I tried to create a loop such that it would index +1 and multiply by 5 for the first 20 elements but it did not output. What am I doing wrong?
#include <iostream>
usingnamespace std;
int main()
{
int array[30];
int i;
// Change 1st 20 elements to (index +1) * 5
for (i=0; i< 20; i++)
{
array[i]= (i+1)*5;
}
// Display array
for (i=0; i<30; i++)
{
cout << array[30] << " ";
}
// Add
return 0;
}
2)I'm assuming for adding into the array based on those directions I had starting at position 20 like this?
[code
// add to array
array [20] = 68;
array [21] = 2;
array [22]= 114;
array [23]=111;
][/code]
3) How should i remove the values 114, 42, 60,2? Loop through for each value? is there a more efficient way?