#include #include #define MAXSIZE 100 void insert(int [],int *); void remove_func(int [],int *); void printing(int [],int *); void sorting_array(int [],int *); int main() { int choice; int size=0; int ar[MAXSIZE]; do { printf("*********************************\n"); printf("*press \"1\" to insert an element**\n"); printf("*press \"2\" to remove an element**\n"); printf("*press \"3\" for printing elements*\n"); printf("*press \"4\" to exit the program***\n"); printf("*********************************\n"); scanf("%d",&choice); switch(choice) { case 1: insert(ar,&size); break; case 2: remove_func(ar,&size); break; case 3: printing(ar,&size); break; case 4: printf("good bye\n"); return 0; default: printf("wrong operation \n"); } } while(choice!=4); return 0; } void insert(int a[],int *size) { sorting_array(a,size); int j; int exist=0; int index=0; int i; int inserted; if(*sizeindex;j--){ a[j]=a[j-1]; } a[index]=inserted; printf("Element %d is inserted\n",inserted); } } else if(*size==MAXSIZE){ printf("The list is full of elements\n"); } } void remove_func(int a[],int *size) { sorting_array(a,size); int index; int exist=0; int i; int remove_it; if(*size>0){ printf("Enter element to remove\n"); scanf("%d",&remove_it); for(i=0;i<*size;i++){ if(remove_it==a[i]){ exist=1; index=i; break; } } if(exist==1){ for(;index<*size-1;index++){ a[index]=a[index+1]; } (*size)--; printf("element %d is removed\n",remove_it); } else if(exist==0){ printf("Element %d does not exist\n",remove_it); } } else if(*size==0){ printf("the list is empty\n"); } } void printing(int a[],int *size) { sorting_array(a,size); int i; if(*size>0){ for(i=0;i<*size;i++){ printf("Element \"%d\" is %d\n",i+1,a[i]); } } else if(*size==0){ printf("there is no elements in the array to print\n"); } } void sorting_array(int a [],int *size){ int i=0,j; int temp; for(i=0;i<*size-1;i++){ for(j=i+1;j<*size;j++){ if(a[i]>a[j]){ temp=a[i]; a[i]=a[j]; a[j]=temp; } } } }