

We have put check before clearing the list to check if list exists or not and if it exists is it already clear or not. By doing this, list will come to its initial form. The function below will clear the list i-e only remove items from the list. Must note that array can never have negative value, but if you assign it this value it means that it doesn’t exist. The function below will simply delete the list by giving negative value to “cl”. *Output: After the listed you have created first by inserting 5 items, if you will run this function the output you will have will be like: You will be prompted to enter the corresponding number of function you want to use and move ahead. The function that is written below will work throughout the code to display a menu of various functions. *17*/ int get_element_by_position ( int ) *15*/ void update_item_by_position ( int, int ) *10*/ void swapp_items_by_position ( int, int ) *06*/ void add_item_by_position ( int, int ) *Below Is the list of functions that we will be using in our code*/ Int cl =- 1 //shows that list is not created yet, “cl=clear” Int cs = 0 //shows that current size of list is zero Int *list = new int // dynamically creating array with size ‘0’ Int total_size = 0 // shows total size of list is zero *By global variable we mean the variables that can be used anywhere in whole code*/ *initialization of global variables and dynamic array */ You can add more functions in it and can extend it to any level using your own customization. It contains menu based working using 19 functions. This code below can be used by beginners as a small project or assignment during semester.
