Skip to main content

Multi Delete in C

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include <stdlib.h>

void main()
	{
	int i,s,index1,index2,loc,data[50];
	char c;
	clrscr();
	printf("HOW MANY ELEMENT YOU WANT FOR ARRAY:\t");scanf("%d",&index1);
	clrscr();
	printf("START ENTERING VALUE:\n");
	for(i=1;i<=index1;i++)
		{
		printf("data[%d]=",i);
		scanf("%d",&data[i]);
		}
	MULTI_DELET:
	printf("\nENTER LOCATION TO DELET:");scanf("%d",&loc);
	if(loc>index1)
		{
		printf("\n\aLOCATION IS OUT OF RANGE.TRY AGAIN...");
		goto MULTI_DELET;
		}
	printf("HOW MANY INDEX YOU WANT TO DELET:\t");scanf("%d",&index2);
	if(index2>index1)
		{
		printf("\n\aOUT OF RANGE.TRY AGAIN...");
		goto MULTI_DELET;
		}

		//SHIFTING//
	s=index1-(loc+index2);
	for(i=0;i<=s;i++)
		{
		data[loc+i]=data[i+loc+index2];
		}
		//DISPLAY//
	 printf("\nAFTER DELETING");
	 for(i=1;i<=index1-index2;i++)
		{
		printf("\ndata[%d]=%d",i,data[i]);
		}
	 index1=index1-index2;
	 if(index1<=0)
		{
		printf("\n\aSORRY.THERE IS NO MORE ELEMENT TO DISPALY..");
		printf("\n\n\t******* GOOD BYE ********");
		delay(3000);
		exit(1);
		}

	 printf("\nDO IT AGAIN ?(y/n)...");
	 c=getch();
	 if(c=='y'||c=='Y')
		{
		goto MULTI_DELET;
		}
	}

Spread the love

Mashkawat Ahsan

I am Mashkawat Ahsan. Wikipedian, Mozillian, tech activist, art lover. Thank you for visiting.

Leave a Reply

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