Untitled
unknown
plain_text
3 years ago
1.3 kB
3
Indexable
Never
// Online C compiler to run C program online #include <stdio.h> #define max 10 int rear = -1, front = -1; int queue[max]; void insertion(int d) { if (rear == max - 1) { printf("\n no space is left"); } else if (front == -1 && rear == -1) { front = 0; rear = 0; } else { rear = rear + 1; } queue[rear] = d; } void display() { for (int i = front; i <= rear; i++) { printf("%d ", queue[i]); } } int deletion() { if (rear == -1 && front == -1) { printf("\n queue is empty"); } else { front = front + 1; } } int main() { int val, option; do { printf("\n MENU "); printf(" \n 1.insertion"); printf("\n 2.dislay"); printf("\n 3.deletion"); printf("\n enter ur option: "); scanf("%d", &option); switch (option) { case 1: printf("\n enter the value to be added : "); scanf("%d", &val); insertion(val); display(); break; case 2: display(); break; case 3: deletion(); display(); break; } } while (option != 4); return 0; }