C Programming Tutorial

 
 
 
 
#include<stdio.h>
#include<conio.h>

void cqinsert();
void cqdelete();
void display();
int n=4,y=0;
int q[4];
int f=-1,r=-1;

void main()
{
int ch;
while(ch!=4)
{
clrscr();
printf(\"********MENU********\\n\");
printf(\"1 for Insert queue\\n\");
printf(\"2 for Delete queue\\n\");
printf(\"3 for Display\\n\");
printf(\"4 for Exit\");
printf(\"\\nEnter ur choice: \");
scanf(\"%d\",&ch);
switch(ch)
{
case 1: cqinsert();
    break;
case 2: cqdelete();
    break;
case 3: display();
    break;
case 4: break;
}
}
}

void cqinsert()
{
int x;
    if(r==n)
    {
    r=0;
    }
    else
    {
    r=r+1;
    }
    if(f==r)
    {
    printf(\"Queue overflow\");
        if(f==0)
        {
        r=n;
        }
        if(f!=0)
        {
        r=r-1;
        }
        getch();
    }
    else
    {
    printf(\"Enter the num:\");
    scanf(\"%d\",&x);
    q[r]=x;
    if(f==-1)
        {
        f=0;
        }
    }
}

void cqdelete()
{

    if(f==-1)
    {
    printf(\"Queue underflow\");
    getch();
    }
    else
    {
        y=q[f];
        if(f==r)
        {
        f=-1;
        r=-1;
        }
        else if(f==n)
        {
        f=0;
        }
        else
        {
        f=f+1;
        }
    }
}

void display()
{
int i;
        if(f<=r)
        {
        for(i=f;i<=r;i++)
            {
            printf(\"%d \",q[i]);
            }
        }
        if(r<f)
        {
        for(i=f;i<=n;i++)
             {
             printf(\"%d \",q[i]);
             }
        for(i=0;i<=r;i++)
             {
             printf(\"%d \",q[i]);
             }
        }

getch();
}

    Related Post:
  1. PROGRAM TO EVALUATE CORRELATION OF TWO SETS OF DATA USING BARRIER

  2. Write a function to perform string operation i.e. split, join, length, substring using pointer without using any string function

  3. Program using structures/file to print name and age of the oldest and the youngest student in the class

  4. Program to multiply two nXn matrix using indirect scheduling in two dimensional matrix

  5. Program to find mode of the given array

  6. Circular link list with create, insert, delete, display operations using structure pointer

  7. NEWTONS DIVIDED DIFFERENCE INTERPOLATION

  8. Program of histogram using loop splitting and locking the each bin with a different lock

  9. Program to find the minimum cost of a spanning tree

  10. Simple program to assign values to many variables in one line

  11. Program to read two positive numbers and interchange its values using +(add) and -(sub) operators and without using any extra variable

  12. Program to find sum, average and deviation of input numbers using parallel processing

  13. PROGRAM FOR 2^N CHILDREN

  14. Program to solve the producer-consumer problem using thread

  15. Program that converts hexadecimal value in decimal, octal and binary.

  16. Program of maintaining employee detail

  17. Program to display menus like windows operating system and also can add as many as user want

  18. Program of addition, subtraction,multiplication and division of rational numbers

  19. Example of using preprocessor - 4 in different files

  20. PROGRAM TO FIND SUM OF ALL INTEGER WHICH IS &gt; 100 AND&lt; 200 AND WHICH IS DIVISIBLE BY 7

 
 
Didn't find what you were looking for? Find more on Program of circular link list