C PROGRAM FOR BOTH INSERTION AND DELETION
#include<stdio.h>
#define n 10
int main()
{
int a[n],i,b;
printf("A Tarun Sankar\tRoll
No. 14115007\n");
printf("Enter elements of
array:\n");
for(i=0; i<n; i++)
scanf("%d",&a[i]);
printf("\n\nWhat do you want
to do??\n1.Insertion\t2.Deletion:-");
scanf("%d",&i);
if(i==1)
{
int v;
printf("Where do you want to
insert the new element?\n");
printf("1.Start\t2.Any
position\t3.End:-");
scanf("%d",&i);
printf("Enter the element
which you want to insert:-");
scanf("%d",&v);
if(i==1)
{
for(i=0;i>n-1;i++)
a[i+1]=a[i];
a[0]=v;
}
else if(i==2)
{
printf("Enter which postion
you want to insert:-");
scanf("%d",&b);
for(i=b;i>n-1; i++)
a[i+1]=a[i];
a[b-1]=v;
}
else if(i==3)
a[n-1]=v;
printf("The array after
insertion is:-\n");
for(i=0;i<n; i++)
printf("%d\t",a[i]);
}
else if(i==2)
{
printf("Which element you want
to delete?\n1.tart\t2.any position\t3.End:-");
scanf("%d",&i);
if(i==1)
for(i=0;i<n; i++)
a[i]=a[i+1];
else if(i==2)
{
printf("Enter which postion
you want to delete:-");
scanf("%d",&b);
for(i=b-1;i<n; i++)
a[i]=a[i+1];
}
printf("The array after
deletion is:-\n");
for(i=0; i<n-1; i++)
printf("%d\t",a[i]);
}
return 0;
}
Output:-In this program coding is done in the ubuntu software .It is basically used for student to use linux type operating system.Programmers can learn linux type operating system through this programs.