SlideShare a Scribd company logo
S5-2
Write a program in ‘C’ language to implement a Dequeue using pointers.
All operations associated with a Dequeue are to be implemented.
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *link;};
void addqatend(struct node**,struct node**,int);
void addqatbeg(struct node**,struct node**,int);
delqatbeg(struct node**,struct node**);
delqatend(struct node**,struct node**);
main()
{
struct node*front,*rear;
int item;
front=rear=NULL;
addqatend(&front,&rear,11);
addqatend(&front,&rear,81);
addqatend(&front,&rear,16);
addqatend(&front,&rear,45);
addqatbeg(&front,&rear,20);
clrscr();
q_display(front);
printf("nnumber of elements in the que=%d",count(front));
printf("nitems taken from qn");
item=delqatbeg(&front,&rear);
printf("%d ",item);
printf("nafter deletionn");
q_display(front);
getch();
}
/*adds a new element at end **/
void addqatend(struct node **f,struct node **r,int item)
{
struct node *q;
q=(struct node*)malloc(sizeof(struct node));
q->data=item;
q->link=NULL;
/**if q empty**/
if(*f==NULL)
*f=q;
else
(*r)->link=q;
*r=q;
}
/*add at begin**/
void addqatbeg(struct node** f,struct node** r,int item)
{
struct node *q;
int t;
Page 1
S5-2
q=(struct node*)malloc(sizeof(struct node));
q->data=item;
q->link=NULL;
/**if q empty**/
if(*f==NULL)
*f=*r=q;
else
q->link=*f;
*r=*f;
*f=q;
}
/*remove from front ***/
delqatbeg(struct node** f,struct node** r)
{
struct node *q; int item;
if(*f==NULL)
printf("q empty");
else
q=*f;item=q->data;
*f=q->link; free(q);
/*if q becom empty after delet*/
if(*f==NULL)
*r=NULL;
return item;
}
/*remove from rear end ***/
delqatend(struct node** f,struct node** r)
{
struct node *q,*rleft,*temp; int item;
temp=*f;
if(*r==NULL)
printf("q empty");
else
/*traverse q to find the prevous element adrs*/
while(temp!=*r)
{rleft=temp; temp=temp->link;}
/*delete the node*/
q=*r;item=q->data;
free(q);
*r=rleft;
(*r)->link=NULL;
/*if q becom empty after delet*/
if(*r==NULL)
*f=NULL;
return item;
}
/*to display**/
q_display(struct node *q)
{
printf("nfront->");
while(q!=NULL)
{
Page 2
S5-2
if(q->link==NULL)
printf("<-rear");
printf("%2d ",q->data);
q=q->link;
}
}
/*count nodes**/
count(struct node *q)
{
int c=0;
while(q!=NULL)
{
q=q->link; c++;}
return c;
}
Page 3

More Related Content

What's hot

Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
Dr. Loganathan R
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Program for pyramid
Program for pyramidProgram for pyramid
Program for pyramidnayakq
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Hitesh Kumar
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
mohdshanu
 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffffmohdshanu
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
Dr. Loganathan R
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
Koshy Geoji
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
Dr. Loganathan R
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
cexpertise
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
 
C program to add n numbers
C program to add n numbers C program to add n numbers
C program to add n numbers
mohdshanu
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
mohdshanu
 

What's hot (20)

Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Program for pyramid
Program for pyramidProgram for pyramid
Program for pyramid
 
week-1x
week-1xweek-1x
week-1x
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
week-11x
week-11xweek-11x
week-11x
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
week-10x
week-10xweek-10x
week-10x
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffff
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
 
week-4x
week-4xweek-4x
week-4x
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
C program to add n numbers
C program to add n numbers C program to add n numbers
C program to add n numbers
 
Shan
ShanShan
Shan
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
 

Viewers also liked

Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013
Jennifer Lingerfelt
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call pptgianbisa
 
Yadira's 37th presentation
Yadira's 37th presentationYadira's 37th presentation
Yadira's 37th presentationDenis Martinez
 
Providing Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking PatronsProviding Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking Patrons
tomastoro
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.docSally15
 
Justia and Amazon CloudSearch
Justia and Amazon CloudSearchJustia and Amazon CloudSearch
Justia and Amazon CloudSearchNick Moline
 
#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass
Nick Moline
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call pptgianbisa
 
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Nick Moline
 
Sarcs sexii power point final
Sarcs sexii power point finalSarcs sexii power point final
Sarcs sexii power point final
Michael Greenwell
 
Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01liveware82
 
まちづくりと復興について
まちづくりと復興についてまちづくりと復興について
まちづくりと復興についてJunichi Toyoshima
 
The story of_intenet_1
The story of_intenet_1The story of_intenet_1
The story of_intenet_1
Jorgelcb
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.docSally15
 

Viewers also liked (20)

DJKrush
DJKrushDJKrush
DJKrush
 
Ning post 2
Ning post 2Ning post 2
Ning post 2
 
Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call ppt
 
Ning post #4
Ning post #4Ning post #4
Ning post #4
 
Yadira's 37th presentation
Yadira's 37th presentationYadira's 37th presentation
Yadira's 37th presentation
 
Providing Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking PatronsProviding Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking Patrons
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.doc
 
Justia and Amazon CloudSearch
Justia and Amazon CloudSearchJustia and Amazon CloudSearch
Justia and Amazon CloudSearch
 
#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass
 
Moby
MobyMoby
Moby
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call ppt
 
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
 
Sarcs sexii power point final
Sarcs sexii power point finalSarcs sexii power point final
Sarcs sexii power point final
 
Ning post #3
Ning post #3Ning post #3
Ning post #3
 
Ning post #2
Ning post #2Ning post #2
Ning post #2
 
Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01
 
まちづくりと復興について
まちづくりと復興についてまちづくりと復興について
まちづくりと復興について
 
The story of_intenet_1
The story of_intenet_1The story of_intenet_1
The story of_intenet_1
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.doc
 

Similar to Bcsl 033 data and file structures lab s5-2

Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docx
PayalJindal19
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
Thesis Scientist Private Limited
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
Johan Thelin
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building Hierarchy
Mohamed Samy
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docx
Komlin1
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Windows Developer
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Eelco Visser
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
Eelco Visser
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Zaibi Gondal
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
AMIT SINGH
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
tristans3
 

Similar to Bcsl 033 data and file structures lab s5-2 (20)

Data struture lab
Data struture labData struture lab
Data struture lab
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docx
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building Hierarchy
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docx
 
C program
C programC program
C program
 
Qe Reference
Qe ReferenceQe Reference
Qe Reference
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 

More from Dr. Loganathan R

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdf
Dr. Loganathan R
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdf
Dr. Loganathan R
 
Ch 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdfCh 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdf
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
Dr. Loganathan R
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information Security
Dr. Loganathan R
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Dr. Loganathan R
 
Session 9 4 alp to display the current system time using dos int 21 h
Session 9  4 alp to display the current system time using dos int 21 hSession 9  4 alp to display the current system time using dos int 21 h
Session 9 4 alp to display the current system time using dos int 21 h
Dr. Loganathan R
 
Session 9 1 alp to compute a grade using procedures
Session 9   1 alp to compute a grade using proceduresSession 9   1 alp to compute a grade using procedures
Session 9 1 alp to compute a grade using procedures
Dr. Loganathan R
 
IGNOU Assembly Language Programming
IGNOU Assembly Language ProgrammingIGNOU Assembly Language Programming
IGNOU Assembly Language Programming
Dr. Loganathan R
 
Requirement engineering process
Requirement engineering processRequirement engineering process
Requirement engineering process
Dr. Loganathan R
 
MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…
Dr. Loganathan R
 
Software requirements
Software requirementsSoftware requirements
Software requirements
Dr. Loganathan R
 
Software process
Software processSoftware process
Software process
Dr. Loganathan R
 
Software engineering critical systems
Software engineering   critical systemsSoftware engineering   critical systems
Software engineering critical systems
Dr. Loganathan R
 
Software engineering socio-technical systems
Software engineering   socio-technical systemsSoftware engineering   socio-technical systems
Software engineering socio-technical systems
Dr. Loganathan R
 
Software engineering introduction
Software engineering   introductionSoftware engineering   introduction
Software engineering introduction
Dr. Loganathan R
 

More from Dr. Loganathan R (18)

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdf
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdf
 
Ch 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdfCh 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdf
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information Security
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
 
Session 9 4 alp to display the current system time using dos int 21 h
Session 9  4 alp to display the current system time using dos int 21 hSession 9  4 alp to display the current system time using dos int 21 h
Session 9 4 alp to display the current system time using dos int 21 h
 
Session 9 1 alp to compute a grade using procedures
Session 9   1 alp to compute a grade using proceduresSession 9   1 alp to compute a grade using procedures
Session 9 1 alp to compute a grade using procedures
 
IGNOU Assembly Language Programming
IGNOU Assembly Language ProgrammingIGNOU Assembly Language Programming
IGNOU Assembly Language Programming
 
Requirement engineering process
Requirement engineering processRequirement engineering process
Requirement engineering process
 
MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…
 
Software requirements
Software requirementsSoftware requirements
Software requirements
 
Software process
Software processSoftware process
Software process
 
Software engineering critical systems
Software engineering   critical systemsSoftware engineering   critical systems
Software engineering critical systems
 
Software engineering socio-technical systems
Software engineering   socio-technical systemsSoftware engineering   socio-technical systems
Software engineering socio-technical systems
 
Software engineering introduction
Software engineering   introductionSoftware engineering   introduction
Software engineering introduction
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 

Bcsl 033 data and file structures lab s5-2

  • 1. S5-2 Write a program in ‘C’ language to implement a Dequeue using pointers. All operations associated with a Dequeue are to be implemented. #include<stdio.h> #include<conio.h> struct node { int data; struct node *link;}; void addqatend(struct node**,struct node**,int); void addqatbeg(struct node**,struct node**,int); delqatbeg(struct node**,struct node**); delqatend(struct node**,struct node**); main() { struct node*front,*rear; int item; front=rear=NULL; addqatend(&front,&rear,11); addqatend(&front,&rear,81); addqatend(&front,&rear,16); addqatend(&front,&rear,45); addqatbeg(&front,&rear,20); clrscr(); q_display(front); printf("nnumber of elements in the que=%d",count(front)); printf("nitems taken from qn"); item=delqatbeg(&front,&rear); printf("%d ",item); printf("nafter deletionn"); q_display(front); getch(); } /*adds a new element at end **/ void addqatend(struct node **f,struct node **r,int item) { struct node *q; q=(struct node*)malloc(sizeof(struct node)); q->data=item; q->link=NULL; /**if q empty**/ if(*f==NULL) *f=q; else (*r)->link=q; *r=q; } /*add at begin**/ void addqatbeg(struct node** f,struct node** r,int item) { struct node *q; int t; Page 1
  • 2. S5-2 q=(struct node*)malloc(sizeof(struct node)); q->data=item; q->link=NULL; /**if q empty**/ if(*f==NULL) *f=*r=q; else q->link=*f; *r=*f; *f=q; } /*remove from front ***/ delqatbeg(struct node** f,struct node** r) { struct node *q; int item; if(*f==NULL) printf("q empty"); else q=*f;item=q->data; *f=q->link; free(q); /*if q becom empty after delet*/ if(*f==NULL) *r=NULL; return item; } /*remove from rear end ***/ delqatend(struct node** f,struct node** r) { struct node *q,*rleft,*temp; int item; temp=*f; if(*r==NULL) printf("q empty"); else /*traverse q to find the prevous element adrs*/ while(temp!=*r) {rleft=temp; temp=temp->link;} /*delete the node*/ q=*r;item=q->data; free(q); *r=rleft; (*r)->link=NULL; /*if q becom empty after delet*/ if(*r==NULL) *f=NULL; return item; } /*to display**/ q_display(struct node *q) { printf("nfront->"); while(q!=NULL) { Page 2
  • 3. S5-2 if(q->link==NULL) printf("<-rear"); printf("%2d ",q->data); q=q->link; } } /*count nodes**/ count(struct node *q) { int c=0; while(q!=NULL) { q=q->link; c++;} return c; } Page 3