C Programming Tutorial

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

int queue[N]={0};
int rear=0,front=0;

void insert(void);
void del(void);
void disp(void);
void cre(void);

void main()
{
    int user=0;

    clrscr();
    while(user!=4)
    {
        clrscr();
        printf(\"\\n\\n\\n\\t\\t\\t THE SIZE OF QUEUE IS %d\",N);
        printf(\"\\n\\t 1.INSERT\");
        printf(\"\\n\\t 2.DELETE\");
        printf(\"\\n\\t 3.DISPLAY\");
        printf(\"\\n\\t 4.EXIT\");
        printf(\"\\n\\t 5.CREATE\");
        scanf(\"%d\",&user);
        switch(user)
        {
            case 1:
                insert();
                break;
            case 2:
                del();
                break;
            case 3:
                disp();
                break;
            case 4:
                printf(\"\\n\\t THANK U\");
                break;
            case 5:
                cre();
                break;
        }
        getch();

    }
    getch();
}



/*********************insert********************/
void insert(void)
{
    int t;
    if(rear<N)
    {
        printf(\"\\n\\t ENTER A VALUE IN QUEUE\");
        scanf(\"%d\",&t);
        queue[rear]=t;
        rear++;
    }
    else
    {
        printf(\"\\n\\t Q OVERFLOW!!!!!!!!!!!!!!!\");
    }
}
void del(void)
{
    int i;
    printf(\"\\n\\t %d gets deleted.........\",queue[front]);
    queue[front]=0;
    front++;
}
void disp(void)
{
    int i;
    for(i=front;i<rear;i++)
    {
        printf(\"\\n\\t %d\",queue[i]);
    }
}
void cre(void)
{

    int t;
    printf(\"\\n\\t ENTER A VALUE IN QUEUE\");
    scanf(\"%d\",&t);
    front=0;
    queue[front]=t;
    rear=front+1;
}

    Related Post:
  1. Example of passing variable values to a function

  2. Program read a file name, serach it in C Drive, if multiple files are found, then display a list of these files with path on the screen...

  3. PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES.INPUT STEPS FROM KEYBORD.SUM=e1+e2+e3+...(TAKE EXP FUNCTION FROM MATH.H)

  4. Program of FIXED POINT METHOD OF NON LINEAR EQUATION

  5. Program to display numbers using do while loop

  6. Program to find the length of a string taken from user without using strlen function

  7. program to find and print first N positive integers whose squares are palindormes........

  8. Program that illustrates the use of malloc and calloc functions

  9. Program to find first occurrence of a character in a string. Function should return characters position in string. (Use strchr function from string.h

  10. PROGRAM TO FIND VOLUME OF A CYLINDER

  11. Program to find matrix addition, subtraction, multiplication, transpose and symmetric operations

  12. Program to maintain a linked list

  13. Program to convert value from one currency to another i.e. from dollar to rupees and rupees to dollar

  14. Example 1 of using structure

  15. PLOTTING OF TWO FUNCTIONS

  16. FUNCTION TABULATED AT UNEQUAL INTERVAL

  17. Program to read a character from KeyBoard using Interrupt 21h

  18. PROGRAM TO READ NUMBERS, N1 AND N2 ARE INTERCHANGE WITHOUT USING EXTRA VARIABLES.N1=10, N2=20 THEN O/P IS N1=20, N2=10 USING MULTIPLICATION, DIVISION

  19. Program to swap elements of array of pointers to strings

  20. PROGRAM SHOWING ROUND-OFF ERRORS IN FLOATING POINT COMPUTATIONS

 
 
Didn't find what you were looking for? Find more on simple queue with array