Task: Write a menu driven program with the menu options:
1. Insert
a. Insert at End
b. Insert at Index
c. Back
2. Edit
3. Delete
4. Search
5. Print
a. Print at Index
b. Print All Records
6. Current No. of Records
7. Exit
Program should be implemented in C/C++ with arrays, pointers and functions
Maximum 50 numbers are allowed by the user to enter
Each menu option should be implemented in separate function.
You are not allowed to use global variables.
Some more details about each menu option:
1. Insert (07 Marks)
Keep asking user to add number into array one by one until user enters 0 as a number (which means that 0 is not allowed to enter as a number). When maximum limit reaches then inform user about that and do not allow entering any more numbers.
a) insertAtEnd(int *array)
Add number at the end of array.
b) insertAtIndex(int *array, int index)
Add number at specific index. Shift all elements forward.
2. Edit (05 Marks)
Ask position in array at which user want to edit the number and also ask which number user want to replace with. When there is no number has been entered by the user at that location
COMSATS Institute of Information Technology
then just replies with a message that the specified position is empty.
edit(int *array, int index)
3. Delete
Ask position from where user wants to delete a value. If value does not exists at specified index then inform user. On successful deletion, shift elements backward.
delete(int *array, int index)
4. Search (05 Marks)
Ask user to enter a number to search from the added numbers (means in array). If number is found then tell the position of the number in the array. When the number exists at multiple positions in array then tell no. of occurrences and their respective positions. When number is not found then reply with a message that number does not exists in array.
search(int *array, int number)
5. Print Numbers (02 Marks)
print(int *array, int index)
If index is negative then print all records, otherwise print value at index. When no value exists at specified index, then inform user about it.
6. Current No. of Records (01 Mark)
Display total numbers entered so far by the user.
7. Exit
Exit program
Hint: You will need to create some functions that will help to reduce redundancy of code. Such as, getSize, initialize, setCurrent, getCurrent