Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define SIZE 100
- int queue[SIZE];
- int start = 0;
- int end = 0;
- void enqueue(int value);
- int dequeue();
- int main()
- {
- enqueue(10);
- enqueue(18);
- printf("%d\n", dequeue());
- enqueue(12);
- enqueue(4);
- printf("%d\n", dequeue());
- printf("%d\n", dequeue());
- printf("%d\n", dequeue());
- return 0;
- }
- void enqueue(int value)
- {
- if(end == SIZE)
- {
- printf("Queue Full\n");
- exit(1);
- }
- queue[end++] = value;
- }
- int dequeue()
- {
- if(start == end)
- {
- printf("Queue Empty\n");
- exit(2);
- }
- return queue[start++];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement