//#include
#include
#include
#include
void main()
{
int arr[20],l,c,p,i;
clrscr();
printf("\nEnter the limit of array----:>");
scanf("%d",&l);
printf("ENTER THE DATA---> ");
for(p=0;p<l;p++)
{
scanf("%d",&arr[p]);
}
while(1)
{
printf("\n1.INPUT\n2.DELETE\n3.VIEW\n4.EXIT\nEntert the choice--> ");
scanf("%d",&c);
switch(c)
{
case 1: clrscr();// CORDING OF INSERT BLOCK
readw:
printf("\nEnter the position---> ");scanf("%d",&p);
if(p>l)
{
printf("\n\t\tARRAY OUT OF LIMIT\n\nPlease re enter your POSITION:\n");
goto readw;
}
else if(p==0)
{
printf("\n\t\tARRAY OUT OF LIMIT\n\nPlease re enter your POSITION:\n");
goto readw;
}
for(i=l;i>=p-1;i--)
arr[i]=arr[i-1];
l=l+1;
printf("Enter the data--<> ");scanf("%d",&arr[p-1]);
break;
case 2: clrscr();// DELETE BLOCK
readd:
printf("\nEnter the position---> ");scanf("%d",&p);
if(p>l)
{
printf("\n\t\tARRAY OUT OF LIMIT\n\nPlease re enter your POSITION:\n");
goto readd;
}
else if(p==0)
{
printf("\n\t\tARRAY OUT OF LIMIT\n\nPlease re enter your POSITION:\n");
goto readd;
}
for(i=(p-1);i<l;i++)
arr[i]=arr[i+1];
l=l-1;
printf("\n\t\t<<--ONE ELEMENT DELETED-->>\n");
break;
case 3: clrscr(); // VIEW BLOCK
printf("\nARRAY ELEMNTS ARE>>\n");
for(i=0;i<l;i++)
printf("\n\t\t%5d pos=%d",arr[i],(i+1));
break;
case 4: //EXIT BLOCK
exit(0);
}
}
}
No comments:
Post a Comment