C Source Code
#include<stdio.h>
void insert(int[],int);
void sort(int[],int);
void deletion(int[],int);
void search(int[],int);
void main()
{ int q,A[50],n,i;
printf("\t\t**************************\n\n\t\t\tArray Operator\n\t\t\tBy Jace Joji\n\n\t\t**************************");
printf("\nEnter array size:");
scanf("%d",&n);
printf("Enter Array:");
for(i=0;i<n;i++)
scanf("%d",&A[i]);
printf("Your array is:");
for(i=0;i<n;i++)
printf("\t%d",A[i]);
do{
printf("\nMenu Options:\n1)Insertion\n2)Sorting\n3)Deletion\n4)Search\n>>>");
scanf("%d",&q);
switch(q){
case 1:insert(A,n);
break;
case 2:sort(A,n);
break;
case 3:deletion(A,n);
break;
case 4:search(A,n);
break;
};
printf("\nPress 0 to return to main menu\nPress 9 to exit()\n>>>");
scanf("%d",&q);
if(q!=0)
printf("Thank you for using our program");
}while(q==0);
}
void search(int A[],int n)
{ int i,s;
printf("\n Enter search parameter:");
scanf("%d",&s);
for(i=0;i<n;i++)
if(s==A[i])
{ printf("\nSearch element found at %dth position",i+1);
break;
}
else
printf("\nSearch element not found at %dth position",i+1);
}
void insert(int A[],int n)
{ int i,s,j;
printf("\n Enter insertion Item:");
scanf("%d",&s);
printf("\n Enter insertion location(index):");
scanf("%d",&j);
for(i=n-1;i>=j;i--)
A[i+1] = A[i];
A[j]=s;
n=n+1;
printf("The modified array is");
for(i=0;i<n;i++)
printf("\t%d",A[i]);
}
void deletion(int A[],int n)
{ int i,j;
printf("\n Enter index of element to be deleted:");
scanf("%d",&j);
for(i=j;i=n-1;i++)
A[i]= A[i+1];
n=n-1;
printf("The modified array is");
for(i=0;i<n;i++)
printf("\t%d",A[i]);
}
void sort(int A[],int n)
{ int i,j,temp;
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
{if(A[j]>A[j+1])
{temp=A[j];
A[j]=A[j+1];
A[j+1]=temp;
}}
printf("The sorted array is:");
for(i=0;i<n;i++)
printf("\t %d",A[i]);
}