PROGRAM OF DELETION FROM ARRAY
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],n,loc,p,i,num;
clrscr();
printf("\n\nEnter the size of list\t:");
scanf("%d",&n);
printf("\n\nEnter the elements of list\t");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n\n\2Your list");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\nif you want delete a number from the list \n Inseart the location");
scanf("%d",&loc);
if(loc>n)
{
printf("You enterd a rong choice\t\2");
}
else
{
loc=loc-1;
while(n>loc)
{
a[loc]=a[loc+1];
loc=loc+1;
}
n=n-1;
printf("\nAfter deletion your list:\n");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
}
getch();
}
#include<conio.h>
void main()
{
int a[100],n,loc,p,i,num;
clrscr();
printf("\n\nEnter the size of list\t:");
scanf("%d",&n);
printf("\n\nEnter the elements of list\t");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n\n\2Your list");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\nif you want delete a number from the list \n Inseart the location");
scanf("%d",&loc);
if(loc>n)
{
printf("You enterd a rong choice\t\2");
}
else
{
loc=loc-1;
while(n>loc)
{
a[loc]=a[loc+1];
loc=loc+1;
}
n=n-1;
printf("\nAfter deletion your list:\n");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
}
getch();
}
No comments:
Post a Comment