URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Class Discussion
  HTML https://srm.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Data Structure
       *****************************************************
       #Post#: 17--------------------------------------------------
       Easy Queue Program (Data Structure)
   DIR By: prannyll
       Date: May 2, 2019, 12:02 pm
       ---------------------------------------------------------
       #include<stdio.h>
       #include<conio.h>
       #define MAX 5
       int queue[MAX], rear = -1, front = -1;
       void enqueue(); void dequeue(); void view();
       void main()
       {
       int ch;
       printf("\n MAIN MENU");
       printf("\n 1. View");
       printf("\n 2. Enqueue");
       printf("\n 3. Dequeue");
       printf("\n Press 0 to Exit.");
       scanf("%d", &ch);
       switch(ch)
       {
       case 0: exit(0);
       break;
       case 1: view();
       break;
       case 2: enqueue();
       break;
       case 3: dequeue();
       break;
       default: printf("WRONG CHOICE!");
       }
       main();
       }
       void view()
       {
       int i;
       if(front > rear || rear <= -1)
       {
       printf("\n QUEUE IS EMPTY");
       front = rear = -1;
       }
       else
       {
       if(front == -1)
       front = 0;
       for(i = front ; i <= rear; i++)
       printf(" %d \t", queue[i]);
       }
       }
       void enqueue()
       {
       if(rear >= MAX)
       printf("\n QUEUE IS FULL");
       else
       {
       rear++;
       printf("\n Enter Element: ");
       scanf("%d", &queue[rear]);
       }
       }
       void dequeue()
       {
       if(rear <= -1 || front > rear)
       {
       printf("\n QUEUE IS EMPTY");
       front = rear = -1;
       }
       else
       {
       printf("\n DELETED : %d", queue[front]);
       front++;
       }
       }
       *****************************************************
       Page 1 of 1