#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,F=0,R=0,n,m,item;
clrscr();
do
{
printf(“Enter
your choice 1-Insertion\n 2-Deletion\n 3-Display\n”);
scanf(“%d”,&n);
switch(n)
{
case 1:
{
if(R==0)
{
printf(“Overflow”);
exit (0);
}
else if(F==0
&& R==0)
{
F=1;
R=1;
printf(“Enter
the element to Insert\n”);
scanf(“%d”,&item);
a[R]=item;
}
else
{
printf(“Enter
the element to insert\n”);
scanf(“%d”,&item);
R=R+1;
a[R]=item;
}
break;
}
case 2:
{
if(R==0)
{
printf(“Underflow”);
}
else
{
item=a[F];
F=F+1;
printf(“The
deleted element is \n %d\n”,item);
}
break;
}
case 3:
{
for(i=R;i>=F;i--)
{
printf(“%d\n”,a[i]);
}
break;
}
default:
{
printf(“Invalid
Input”);
break;
}
}
printf(“Press
5 to continue:\n”);
scanf(“%d”,&n);
}
while(m==5)
getch();
}
No comments:
Post a Comment