#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[60];
int size, n, i, j;
printf("Enter array size:");
scanf("%d",&size);
printf("Enter values in array:\n");
for(i=0; i<size; i++)
{
scanf("%d", a[i]);
}
printf("Enter value to delete :");
scanf("%d",&n);
// Loop to find value in array
for(i=0; i<size; i++)
{
if(n == a[i])
{
break;
}}
//Loop to delete value from array
for(j=i; i<size; j++)
{
a[j] = a[j+1];
}
// Print array's values after deletion
printf("\nArray's values after deletion - - -\n")
for(i=0; i<size; i++)
{
printf("%d\n", a[i]);
}
getch();
}
----------------------------
OUTPUT
----------------------------
Enter array size: 5
Enter values in array:
6
7
3
4
8
Enter value to delete: 3
Array's values after deletion - - -
6
7
4
8
SEARCHING IN ARRAY >>
No comments:
Post a Comment