Array Deletion in C Programming

Array Deletion in C Programming

How to delate an Array Character form an Array in C Programming.
In this article we will learn about how to delete a character form array in c programming language.

#include<stdio.h>
void main()
{
	int a[10]={0},i,j,k,l,n,m,d;
	printf("Enter Element to Enter ");
	scanf("%d",&n);
	n--;
	printf("Enter %d elements \n",n+1);
	for(i=0; i<=n; i++)
	{
		scanf("%d",&a[i]);	
	}	
	printf("You Have Entered : \n");
	for(j=0;j<=n; j++)
	{
		printf("%d\n",a[j]);	
	}
	printf("Enter Element Number To Delete :");
	scanf("%d",&d);
	d--;
	for(l=0; l<n+1; l++)
	{
		if(l>=d)		
		a[l]=a[l+1];
	}
	for(k=0;k<=n; k++)
	{
		if(a[k]!=0)
		printf("%d\n",a[k]);	
	}
	
}

 

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *