Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int a[100],n,f=0,r=0,x=0,d=0;
- void cre()
- {
- if(x==0)
- {
- int i;
- printf("\nEnter the value of Queue:\n");
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- a[i]=0;
- }
- x=1;
- }
- else
- {
- if((f==0 && r==n) || f==r+1)
- {
- printf("\n Queue is Full");
- }
- else
- {
- if(r==n)
- {
- r=1;
- }
- printf("\nEnter the Queue value:\n");
- int b;
- scanf("%d",&b);
- if(f==0)
- {
- d=0;
- }
- if(d==0)
- {
- f=1;
- d=1;
- }
- r++;
- a[r]=b;
- }
- }
- }
- void del()
- {
- if(r==0 && r==0)
- {
- printf("\nQueue is overflowed.\n");
- }
- else
- {
- if(f==n)
- {
- f=1;
- }
- else if(f==r)
- {
- f=0;
- r=0;
- }
- else
- {
- a[f] = 0;
- f++;
- }
- }
- }
- void dis()
- {
- int i;
- for(i=1;i<=n;i++)
- {
- printf("%d ",a[i]);
- }
- }
- int main()
- {
- int x;
- while(1)
- {
- printf("\n1:Ins,2:Del,3: Dis:\n");
- scanf("%d",&x);
- switch(x)
- {
- case 1:
- {
- cre();
- break;
- }
- case 2:
- {
- del();
- break;
- }
- case 3:
- {
- dis();
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement