Posted By

Linear Queue in C programming Language Insert Display Delete

Education 72

#include<stdio.h>

#define size 5

int q[size],front=-1,rear=-1;


void push(){

    int item;

    if(rear==size-1){

        printf("Queue is overflow\n");

        return;

    }

    printf("Enter your item:");

    scanf("%d",&item);

    rear=rear+1;

    q[rear]=item;

}


void pop(){

    int item;

    if(front==-1){

        printf("Jinn er nanu ese inserst kore rakhcilo naki\n");

    }

    else if(front==size+1){

        printf("Queue is empty\n");

    }

    item=q[front];

    front=front+1;

    

}


void disp(){

    int i;

    if (rear==-1)

        printf("Inserting not start yet: \n");

        else if(front==size-1){

            printf("Queue full but no data");

        }

    else

    {

        printf("Queue is ");

        if(front==-1)

            front=front+1;

        for (i = front; i <= rear; i++)

            printf("%d ", q[i]);

        printf("\n");

    }

}


int main(){

    int ch;

    while(1){

        printf("\n1.PUSH\n2.POP\n3.DISPLAY\n4.EXIT\n");

        printf("Enter your choice:");

        scanf("%d",&ch);

        if(ch==1)

            push();

        else if(ch==2)

            pop();

        else if(ch==3)

            disp();

        else if(ch==4)

            break;

        else

            printf("Invalid Choice\n");

    }

    return 0;

}

Linear Queue in C programming Language Insert Display Delete

Login to comment login

Latest Jobs
  • Bangladesh Inland Water Transport Authority Junior River Surveyor Job Circular
    Bangladesh Inland Water Transport Authority
    Education: Bachelor Degree
    Experience: 0 Years
    Deadline: 10 Feb 2019
  • Bangladesh Inland Water Transport Authority River Surveyor Job Circular
    Bangladesh Inland Water Transport Authority
    Education: Bachelor Degree
    Experience: 0 Years
    Deadline: 10 Feb 2019
  • Bangladesh Navy Sub Assistant Engineer Job Circular
    Bangladesh Navy
    Education: B.Sc in Mechanical/ Computer Science Engineering
    Experience: 0 Years
    Deadline: 9 Feb 2019
  • LankaBangla Finance Limited Trainee Credit Analyst Job Circular
    LankaBangla Finance Limited
    Education: Graduate/Post Graduate
    Experience: 0 Years
    Deadline: 2 Feb 2019
  • Jahangirnagar University Store Keeper Job Circular
    Jahangirnagar University
    Education: Bachelor Degree
    Experience: 0 Years
    Deadline: 7 Feb 2019