/* PROGRAM TO IMPLEMENT LINEAR QUEUE USING ARRAY*/

/*include header files*/
#include<stdio.h>
#include<conio.h>

int queue[5];
long front,rear;

void main()
{
int choice,info;

clrscr();

//Initialising queue
initqueue();

while(1)
{
clrscr();
//Displaying menu
printf(" MENU \n");
printf("1.Push an element in queue\n");
printf("2.Pop an element from queue\n");
printf("3.Display the queue\n");
printf("4.Exit!\n");

printf("Your choice: ");
scanf("%i",&choice);

switch(choice)
{
case 1:if(rear<4)
{
printf("enter the number");
scanf("%d",&info);

if (front==-1)
{
front=0;
rear=0;
}

else
rear=rear+1;

queue[rear]=info;
}

else
printf("queue is full");

getch();
break;

case 2: int info;

if(front!=-1)
{
info=queue[front];

if(front==rear)
{
front=-1;
rear=-1;
}

else
front=front+1;

printf("no deleted is = %d",info);
}

else
printf("queue is empty");

getch();
break;

 

case 3: display();
getch();
break;

case 4: exit();
break;

default:printf("You entered wrong choice!");

getch();
break;
}
}
}

void initqueue()
{
//Initialising front & rear to -1
front=rear=-1;
}

/*displays the current position of the queue*/
void display()
{
int i; //For loop driver

//Displaying elements in queue
for(i=front;i<=rear;i++)

printf("%i\n",queue[i]);
}

 

/*output of the program*/

Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement 
Corporate Services
  Web Design and development
  Web Promotion (SEO)
  Multimedia/CD Presentation
  Software development

  E.Commerce

Training@balujalabs

  Software Courses
  Hardware Courses
  Networking.Courses
  Mobile Repairing Courses
  UGC Degrees
Student Corner
 Programming & Projects
 Placement Papers
 Project Ideas
 Synopsis Ideas

  Franchise Section

 Administrator
Franchise Inquiry
 
 

Program to implement linear queue using arrays.

 

 

 

 

 

 

 

 

 

                                                                                                                                          

1 Program to implement linear queue using arrays
2 Program to illustrate the working of a queue when implemented using pointers
3 Program to implement circular queue using pointers
4 To implement queue using arrays.
5 To implement queue using pointers.

 

     
Home       |      About Us       |     Portfolio       |      Services       |       Career        |    Contact Us       |      Industrial Training        |      Achievement