Program to delete an element from the array



//Header Files
#include<stdio.h>
#include<conio.h>
#include<process.h>

int arr[10],n,i,j,k,item,loc;
void main()
{
clrscr();
printf("Enter size of array:");
scanf("%d", &n);

if(n>10)
{
    printf("Entered value exceed the limit of array");
    getch();
    exit(0);
}

printf("\n Enter array elements....");
for(i=0;i<=n-1;i++)
    scanf("%d",&arr[i]);

printf("Enter the location of the element to be deleted...");
scanf("%d",&loc);
item=arr[loc];
for(j=loc;j<=n-2;j++)
    arr[j]=arr[j+1];

printf("\n Array after Deletion...");
k=0;

while(k<=n-2)
{
    printf("\n");
    printf("%d", arr[k]);
    k=k+1;
}
getch();
}

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart