A Simple programme to manipulate array program
#include<stdio.h>
#include<conio.h>
void
main()
{
int
a[100],i,j=0,n,del;
clrscr();
printf("***********
DELETE AN PARTICULAR ITEM FROM ARRAY *************** \n \n");
printf("Enetr
the Array limit:");
scanf("%d",&n);
printf("\n
Enter the Array Value:");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
j=i;
printf("\n
Array address Array Location Arraay Value\n");
for(i=0;i<n;i++)
{
printf("%u\t\t%d\t\t%d\n",&a[i],i,a[i]);
}
printf("\nEnetr
the Delete item:");
scanf("%d",&del);
printf("\n\n********
AFTER DELETING ARRAY ************* \n");
printf("ARRAY
ADDRESS \t ARRAY LOCATION ARRAY VALUE\n");
for(i=0;i<n;i++)
{
if(a[i]==del)
{
a[i]=a[i+1];
i++;
}
if(i!=j)
{
printf("%u\t\t
%d \t\t %d\n",&a[i],i,a[i]);
}
}
getch();
}
Output:
*********** DELETE AN PARTICULAR ITEM FROM ARRAY ***************
Enetr
the Array limit:5
Enter the Array Value:1
2
3
4
5
Array address Array Location Arraay Value
9168 8783 0
9170 8783 1
9172 8783 2
9174 8783 3
9176 8783 4
Enetr the Delete item:4
******** AFTER DELETING ARRAY *************
ARRAY ADDRESS ARRAY LOCATION ARRAY VALUE
9168 8783 0
9170 8783 1
9172 8783 2
9176 8783 4
No comments:
Post a Comment