google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C program in data structure in queue for character DMA Queue

Monday, April 6, 2015

C program in data structure in queue for character DMA Queue

C program in data structure in queue. For character DMA Queue

#include<stdio.h>
#include<conio.h>
#include<process.h>
void insert();
void deletes();
void display();
struct node
{
 char info;
 struct node *link;
}*front=NULL,*rear=NULL;
void main()
{
 int n;
 clrscr();
 while(1)
 {
  printf("\n **menu**\n");
  printf("\n 1. insert \n 2. deletes");
  printf("\n 3. display \n 4. exit");
  printf("\n Enter your choice:- ");
  scanf("%d",&n);
  switch(n)
  {
   case 1 : insert();
   break;
   case 2 : deletes();
   break;
   case 3 : display();
   break;
   case 4 : exit(0);
  }
 }
 getch();
}

void insert()
{
 struct node *temp,*q;
 char x;
 temp=(struct node *)malloc(sizeof(struct node));
 if(temp==NULL)
 {
  printf("\n Insufficient memory");
 }
 else
 {
  printf("\n Enter character:-");
  scanf("%c",&x);
  temp->info=x;
  temp->link=NULL;
  if(rear==NULL&&front==NULL)
  {
   rear=temp;
   front=temp;
  }
  else
  {
   q=rear;
   while(q->link!=NULL)
   {
     q=q->link;
   }
   q->link=temp;
  }
 }
}

void deletes()
{
 struct node *q;
 if(front==NULL&&rear==NULL)
 {
  printf("\n Queue is empty");
 }
 else
 {
   front=rear;
   rear=front->link;
   printf("\n deleted node is %c",front->info);
   free(front);
 }
}

void display()
{
 struct node *q;
 if(front==NULL&&rear==NULL)
 {
  printf("\n Queue is empty");
 }
 else
 {
  front=rear;
  while(front!=NULL)
  {
   printf("\n %c",front->info);
   front=front->link;
  }
 }
}

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...