#include<stdio.h>
#include<conio.h>
void main()
{ int queue[10],max=10,i,ch,c,item,front=-1,rear=-1,c2;
clrscr();
again:
c=1;
printf("QUEUE MENU: ");
printf("\n1.Insertion(Press 1)\n2.Deletion(Press 2)\n3.Display Queue(Press 3):\n");
scanf("%d",&ch);
if(ch==1)
{ while(c==1)
{ if(rear==max)
{ printf("\nOverflow !!!! ");
break; }
printf("\nEnter The Element To Be Inserted In Queue: ");
scanf("%d",&item);
if(front==-1&&rear==-1)
{ front=rear=0; }
else
rear++;
queue[rear]=item;
printf("\nQueue After Insertion Is: ");
for(i=front;i<=rear;i++)
{ printf("%d\t",queue[i]); }
printf("\nWant To Insert More ?? Press 1 for Yes and 2 For No: \n");
scanf("%d",&c);
}}
else if(ch==2)
{ while(c==1)
{ if(front==-1||front==rear+1)
{ printf("\nUnderFlow !!!!");
break; }
front++;
printf("Queue After Deletion Is: ");
for(i=front;i<=rear;i++)
{ printf("%d\t",queue[i]); }
printf("\nWant To Delete More ?? Press 1 for Yes and 2 For No: \n");
scanf("%d",&c); }}
else if(ch==3)
{ if(front==-1||front==rear+1)
printf("Queue Is Empty !!! ");
else
{ printf("Queue Is: ");
for(i=front;i<=rear;i++)
{ printf("%d\t",queue[i]); }
}}
else
printf("Invalid Choice !!!!!! ");
printf("\n1.Back To Main Menu(Press 1)\n2.Exit(Press Any Key):\n");
scanf("%d",&c2);
if(c2==1)
goto again;
}
#include<conio.h>
void main()
{ int queue[10],max=10,i,ch,c,item,front=-1,rear=-1,c2;
clrscr();
again:
c=1;
printf("QUEUE MENU: ");
printf("\n1.Insertion(Press 1)\n2.Deletion(Press 2)\n3.Display Queue(Press 3):\n");
scanf("%d",&ch);
if(ch==1)
{ while(c==1)
{ if(rear==max)
{ printf("\nOverflow !!!! ");
break; }
printf("\nEnter The Element To Be Inserted In Queue: ");
scanf("%d",&item);
if(front==-1&&rear==-1)
{ front=rear=0; }
else
rear++;
queue[rear]=item;
printf("\nQueue After Insertion Is: ");
for(i=front;i<=rear;i++)
{ printf("%d\t",queue[i]); }
printf("\nWant To Insert More ?? Press 1 for Yes and 2 For No: \n");
scanf("%d",&c);
}}
else if(ch==2)
{ while(c==1)
{ if(front==-1||front==rear+1)
{ printf("\nUnderFlow !!!!");
break; }
front++;
printf("Queue After Deletion Is: ");
for(i=front;i<=rear;i++)
{ printf("%d\t",queue[i]); }
printf("\nWant To Delete More ?? Press 1 for Yes and 2 For No: \n");
scanf("%d",&c); }}
else if(ch==3)
{ if(front==-1||front==rear+1)
printf("Queue Is Empty !!! ");
else
{ printf("Queue Is: ");
for(i=front;i<=rear;i++)
{ printf("%d\t",queue[i]); }
}}
else
printf("Invalid Choice !!!!!! ");
printf("\n1.Back To Main Menu(Press 1)\n2.Exit(Press Any Key):\n");
scanf("%d",&c2);
if(c2==1)
goto again;
}
No comments:
Post a Comment