PROGRAM:-
#include<stdio.h>
#define MAX 5
int f=-1,r=-1,cq[MAX];
void ins(); void delt(); void dis();
//this program is developed by thezenithcoder.blogspot.com
void main()
{ int cho=123;
while(cho<4||cho==123)
{printf("1.INSERT\n2.DELETE\n3.DISPLAY\n4.EXIT\n");
printf("Enter your choice:");
scanf("%d",&cho);
switch(cho)
{case 1: ins(); printf("\n"); break;
case 2: delt(); printf("\n"); break;
case 3: dis(); printf("\n"); break;
default:printf("\nThank You.\nHave a Nice day.\n");
}
}
}
//this program is developed by thezenithcoder.blogspot.com
void ins()
{ if((f==0 && r==MAX-1)||(f==r+1)) printf("Circuler Queue is full.\n");
else{ if(f==-1){ f=0; } else if(r==MAX-1){ r=-1; }
printf("Enter your item to insert:");
r++; scanf("%d",&cq[r]); }
}
//this program is developed by thezenithcoder.blogspot.com
void delt()
{ int item;
if(f==-1) printf("Circuler Queue is empty.\n");
else{ if(f==r){ r=0; f=0; } else if(f==MAX-1){ f=0; }
item=cq[f]; printf("%d is deleted.\n",item); f++;}
}
//this program is developed by thezenithcoder.blogspot.com
void dis()
{ int i;
if(f==-1) printf("Circuler Queue is empty.\n");
else{ if(f<=r) { for(i=0;i<MAX;i++){ if(i>=f && i<=r) printf(" %d ",cq[i]);
else printf(" __ "); } }
else{ for(i=0;i<=r;i++) printf(" %d ",cq[i]);
for(i=r+1;i<f;i++) printf(" __ ");
for(i=f;i<MAX;i++) printf(" %d ",cq[i]); }
}
printf("\n");
}
#include<stdio.h>
#define MAX 5
int f=-1,r=-1,cq[MAX];
void ins(); void delt(); void dis();
//this program is developed by thezenithcoder.blogspot.com
void main()
{ int cho=123;
while(cho<4||cho==123)
{printf("1.INSERT\n2.DELETE\n3.DISPLAY\n4.EXIT\n");
printf("Enter your choice:");
scanf("%d",&cho);
switch(cho)
{case 1: ins(); printf("\n"); break;
case 2: delt(); printf("\n"); break;
case 3: dis(); printf("\n"); break;
default:printf("\nThank You.\nHave a Nice day.\n");
}
}
}
//this program is developed by thezenithcoder.blogspot.com
void ins()
{ if((f==0 && r==MAX-1)||(f==r+1)) printf("Circuler Queue is full.\n");
else{ if(f==-1){ f=0; } else if(r==MAX-1){ r=-1; }
printf("Enter your item to insert:");
r++; scanf("%d",&cq[r]); }
}
//this program is developed by thezenithcoder.blogspot.com
void delt()
{ int item;
if(f==-1) printf("Circuler Queue is empty.\n");
else{ if(f==r){ r=0; f=0; } else if(f==MAX-1){ f=0; }
item=cq[f]; printf("%d is deleted.\n",item); f++;}
}
//this program is developed by thezenithcoder.blogspot.com
void dis()
{ int i;
if(f==-1) printf("Circuler Queue is empty.\n");
else{ if(f<=r) { for(i=0;i<MAX;i++){ if(i>=f && i<=r) printf(" %d ",cq[i]);
else printf(" __ "); } }
else{ for(i=0;i<=r;i++) printf(" %d ",cq[i]);
for(i=r+1;i<f;i++) printf(" __ ");
for(i=f;i<MAX;i++) printf(" %d ",cq[i]); }
}
printf("\n");
}
OUTPUT:-
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:1
Enter your item to insert:1
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:1
Enter your item to insert:3
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:1
Enter your item to insert:5
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:1
Enter your item to insert:7
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:1
Enter your item to insert:9
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:3
1 3 5 7 9
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:2
1 is deleted.
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:2
3 is deleted.
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:3
__ __ 5 7 9
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:1
Enter your item to insert:2
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:3
2 __ 5 7 9
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter your choice:4
Thank You.
Have a Nice Day.
0 Comments