123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program for Queue implementation through Linked List.

--------------------------------------------------------------------------------



#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *link;
} ;
struct node *front, *rear;
void main()
{

int wish,will,a,num;
void add(int);

wish=1;
clrscr();
front=rear=NULL;

printf("Program for Queue as Linked List demo..<BR>);
while(wish == 1)
{
printf("
Main Menu
1.Enter data in queue
2.Delete from queue<BR>);
scanf("%d",&will);
switch(will)
{
case 1:
printf("
Enter the data");
scanf("%d",&num);
add(num);
//display();
break;
case 2:
a=del();
printf("
Value returned from front of the queue is %d",a);
break;
default:
printf("
Invalid choice");
}
printf("
Do you want to continue, press 1");
scanf("%d",&wish);
}
getch();
}

void add(int y)
{
struct node *ptr;
ptr=malloc(sizeof(struct node));
ptr->data=y;
ptr->link=NULL;
if(front ==NULL)
{
front = rear= ptr;
}
else
{
rear->link=ptr;
rear=ptr;
}
}


int del()
{
int num;
if(front==NULL)
{
printf("

QUEUE EMPTY
<BR>);
return(0);
}
else
{
num=front->data;
front = front->link;
printf("
Value returned by delete function is %d <BR>,num);
return(num);
}
}

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG