Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Data File StructureRSS Feeds

Queue with array

Posted By: Ruby Brown     Category: C Programming     Views: 3220

Write a program of queue with array.

Code for Queue with array in C Programming

#include<conio.h>
#include<stdio.h>
#define N 5

int queue[N]={0};
int qptr=0;
void  main()
{
    int ch=0;
    clrscr();
    while(ch!=5)
    {
        printf("\n\t 2.INSERT");
        printf("\n\t 3.DELETE");
        printf("\n\t 4.DISPLAY");
        printf("\n\t 5.EXIT");
        scanf("%d",&ch);
        if(ch==2)
        {
            ins();
        }
        if(ch==3)
        {
            del();
        }
        if(ch==4)
        {
            dis();
        }
        if(ch==5)
        {
            printf("\n\n\n\n\n\t\t\t THANK U ");
        }
    }
    getch();
}
void ins(void)
{
    int t;
    printf("\n\t NTER A VALUE::: ");
    scanf("%d",&t);
    queue[qptr]=t;
    qptr++;
}


void del(void)
{
    int i,temp,j;
    if(qptr==0)
    {
        printf("\n\t UNDERFLOW ");
    }
    else
    {
        printf("\n\t THE VALUE REMOVED IS:::::: %d",queue[0]);
        for(i=0;j=i+1;j<qptr;)
        {
            queue[i]=queue[j];
            i++;
            j++;
        }
    }
}
  
Share: 


Didn't find what you were looking for? Find more on Queue with array Or get search suggestion and latest updates.

Ruby Brown
Ruby Brown author of Queue with array is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!