Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #define SIZE 5
- void enQueue(int);
- void deQueue();
- void display();
- int items[SIZE], front = -1, rear = -1;
- int main()
- {
- int a,b,c,d;
- scanf("%d",&a);
- for(b=0; b<a; b++)
- {
- scanf("%d",&c);
- enQueue(c);
- }
- display();
- scanf("%d",&a);
- for(b=0; b<a; b++)
- {
- deQueue(c);
- }
- display();
- return 0;
- }
- void enQueue(int value)
- {
- if(rear == SIZE-1)
- printf("\nQueue is Full!!");
- else
- {
- if(front == -1)
- front = 0;
- rear++;
- items[rear] = value;
- printf("\nInserted -> %d", value);
- }
- }
- void deQueue()
- {
- if(front == -1)
- printf("\nQueue is Empty!!");
- else
- {
- printf("\nDeleted : %d", items[front]);
- front++;
- if(front > rear)
- front = rear = -1;
- }
- }
- void display()
- {
- if(rear == -1)
- printf("\nQueue is Empty!!!");
- else
- {
- int i;
- printf("\nQueue elements are:\n");
- for(i=front; i<=rear; i++)
- printf("%d\t",items[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement