Documente Academic
Documente Profesional
Documente Cultură
Name ____________________________
#include <iostream>;
using namespace std;
int main( ) {
const int CAPACITY = 20;
int numbers[CAPACITY];
int numElements = 0;
return 0;
}
1) Program should display the following console input menu which loops:
Array Manipulation
------------------
1. Get Index
2. Append
3. Insert
4. Remove
5. Remove First
6. Remove Last
7. Output
8. Exit program
Select:
1) output
a) read only parameters
b) outputs the array as a horizontal row of elements with spaces.
c) outputs the size of the array on the same line.
Example: Array: 10 20 30 40 50 Size: 5
2) append
a) add the specified element to the end of the array.
b) isFull should be used as a helper function
3) insertAt
a) insert element at specified position
b) isFull should be used as a helper function
4) removeFirst
a) remove the first element in the array.
b) return the first element in the array.
5) removeLast
a) remove the last element in the array.
b) return the last element in the array.
6) removeElement
a) remove specified element from the array.
b) return the removed element.
c) getIndex should be used as a helper function.
1) isFull
a) returns true if numElements == CAPACITY
2) getIndex
a) returns index of element if element exists, -1 otherwise
b) make use of containsElement helper function
3) containsElement
a) returns true if element exists in the array, false otherwise
1) Remove First
2) Remove Last
3) Get Index 55
3) Insert 55
4) Remove 70
5) Append 110
6) Output
7) End Program