//DATA STRUCTURE
//TOPIC:ARRAY
//AUTHOR:DARSHIT VORA
//program to perfom insertion and deletion from array from specified position
#include < stdio.h >
#include < conio.h >
void main()
{
int a[20],i,ele,n,pos;
clrscr();
printf("\n\n Enter the size of the array: ");
scanf("%d",&n);
printf("\n Enter %d elements: ",n-1);
for (i=0;i < n-1;i++)
scanf ("%d",&a[i]);
printf("\n\n Array: ");
for(i=0;i printf("%d ",a[i]);
//INSERTION
printf("\n\n Enter the element you want to insert: ");
scanf("%d",&ele);
printf("\n Enter the position of insertion: ");
scanf("%d",&pos);
for(i=n-1;i>=pos;i--)
a[i]=a[i-1];
a[i]=ele;
printf("\n\n Array: ");
for(i=0;i printf("%d ",a[i]);
//DELETION
printf("\n Enter the position of the element you want to delete: ");
scanf("%d",&pos);
a[pos-1]=NULL;
for(i=pos;i a[i-1]=a[i];
printf("\n\n Array: ");
for(i=0;i printf("%d ",a[i]);
getch();
}
//TOPIC:ARRAY
//AUTHOR:DARSHIT VORA
//program to perfom insertion and deletion from array from specified position
#include < stdio.h >
#include < conio.h >
void main()
{
int a[20],i,ele,n,pos;
clrscr();
printf("\n\n Enter the size of the array: ");
scanf("%d",&n);
printf("\n Enter %d elements: ",n-1);
for (i=0;i < n-1;i++)
scanf ("%d",&a[i]);
printf("\n\n Array: ");
for(i=0;i
//INSERTION
printf("\n\n Enter the element you want to insert: ");
scanf("%d",&ele);
printf("\n Enter the position of insertion: ");
scanf("%d",&pos);
for(i=n-1;i>=pos;i--)
a[i]=a[i-1];
a[i]=ele;
printf("\n\n Array: ");
for(i=0;i
//DELETION
printf("\n Enter the position of the element you want to delete: ");
scanf("%d",&pos);
a[pos-1]=NULL;
for(i=pos;i
printf("\n\n Array: ");
for(i=0;i
getch();
}
Comments
Post a Comment