SlideShare a Scribd company logo
These are the 4 functions
#include KiostreamP using namespace std; stuct godeType. int info; aodeNype link; void
createList(nodeType*& first, nodeType & last); void printList nodeType & first int main(0
nodeType first, last unt numi greateList first, last) printList(first); SystemC PAUSE"); return 0;
void createList nodeType & first, nodeType & last) int number; nodeType *newNode;
Solution
//EXAMPLE PROGRAM FOR SINGLE LINKED LIST
# include
# include
# include
struct node
{
int number;
node *next;
};
class singlelist
{
node *first,*prev,*temp,*curr;
public:
singlelist()
{
first=NULL;
}
void create()
{
cout<<"Stop by -999"<>temp->number;
while(temp->number!=-999)
{
temp->next=NULL;
if(first==NULL)
{
first=temp;
prev=first;
}
else
{
prev->next=temp;
prev=temp;
}
temp=new node;
cin>>temp->number;
} //end of while
}
void deletenode()
{
int num;
cout<<" Enter the number to delete ";
cin>>num;
if(first->number==num)
{
first=first->next;
return;
}
else
{
prev=first;
curr=first->next;
while(curr->next!=NULL)
{
if(curr->number==num)
{
prev->next=curr->next;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==num)
{
prev->next=NULL;
return;
}
cout<<" No such number";
}
void insertbefore()
{
int nu;
temp=new node;
cout<<" Enter the number ";
cin>>temp->number;
cout<<" before the number ";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first;
first=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
cout<<" No such number ";
}
void insertafter()
{
int nu;
temp=new node;
cout<<" Enter the number ";
cin>>temp->number;
cout<<" After the number ";
cin>>nu;
temp->next=NULL;
prev=first;
curr=first;
/* if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}*/
if(curr->number==nu)
{
temp->next=first->next;
first->next=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
temp->next=curr->next;
curr->next=temp;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
curr->next=temp;
temp->next=NULL;
return;
}
cout<<" No such number ";
}
void print()
{
cout<<" The list is "<number<<"-->";
temp=temp->next;
}
cout<<"Nil"<>ch;
switch(ch)
{
case 1:
s.insertbefore();
s.print();
break;
case 2:
s.insertafter();
s.print();
break;
case 3:
s.deletenode();
s.print();
break;
case 4:
s.print();
break;
case 5:
s.print();
exit(1);
}
}
getch();
}

More Related Content

DOCX
Lab Week 2 Game Programming.docx
PDF
operating system linux,ubuntu,Mac#include iostream #include .pdf
PDF
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
PDF
#includeiostream#includecstdio#includecstdlibusing names.pdf
PDF
take the following code and give details of what each line of code i.pdf
PDF
Write a C program that reads the words the user types at the command.pdf
PDF
The purpose of this C++ programming project is to allow the student .pdf
PDF
Object Oriented Programming (OOP) using C++ - Lecture 5
Lab Week 2 Game Programming.docx
operating system linux,ubuntu,Mac#include iostream #include .pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
take the following code and give details of what each line of code i.pdf
Write a C program that reads the words the user types at the command.pdf
The purpose of this C++ programming project is to allow the student .pdf
Object Oriented Programming (OOP) using C++ - Lecture 5

Similar to These are the 4 functions #include KiostreamP using namespac.pdf (20)

DOCX
#include stdafx.h #include iostream using namespace std;vo.docx
PDF
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
PDF
How do you stop infinite loop Because I believe that it is making a.pdf
PDF
#include &lt;stdio.h&gt; #include &lt;malloc.h&gt; #define ISEMP.pdf
PPT
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
PDF
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
PDF
In C++Write a recursive function to determine whether or not a Lin.pdf
PPT
Doublylinklist
PDF
Exercise2You are to develop a simple queue system for a customer .pdf
TXT
PDF
mainpublic class AssignmentThree {    public static void ma.pdf
PPTX
data structure3.pptx
PPTX
RTTI and Namespaces.pptx ppt of c++ programming language
PDF
Change the driver file (the main .cpp) so that it asks the user to e.pdf
PDF
#include iostream #includestdlib.h using namespace std;str.pdf
PDF
#includeiostream struct node {    char value;    struct no.pdf
PDF
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
PDF
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
PDF
Keep getting a null pointer exception for some odd reasonim creati.pdf
DOCX
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
#include stdafx.h #include iostream using namespace std;vo.docx
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
#include &lt;stdio.h&gt; #include &lt;malloc.h&gt; #define ISEMP.pdf
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
Doublylinklist
Exercise2You are to develop a simple queue system for a customer .pdf
mainpublic class AssignmentThree {    public static void ma.pdf
data structure3.pptx
RTTI and Namespaces.pptx ppt of c++ programming language
Change the driver file (the main .cpp) so that it asks the user to e.pdf
#include iostream #includestdlib.h using namespace std;str.pdf
#includeiostream struct node {    char value;    struct no.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
Consider L = {a^nb^2nc^P p 0}. Prove L is not a context-free langu.pdf
Keep getting a null pointer exception for some odd reasonim creati.pdf
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx

More from JUSTSTYLISH3B2MOHALI (20)

PDF
In a business projects What material is typically contained in a pro.pdf
PDF
Implement the following flowchart in java. Start Request integer k f.pdf
PDF
If no chiasma forms between homologous chromosomes, what happens Th.pdf
PDF
If two organims form a symbiotic realtionship where they share t.pdf
PDF
I would appreciate help with these 4 questions. Thank You.1) Expla.pdf
PDF
How do I know when to use the sin^2+cos^2=1 identity....12 angle id.pdf
PDF
I have a stack in Java populated with integers. Im trying to compa.pdf
PDF
Hint List of commands to read and use use of wild card characters .pdf
PDF
Explain in Detail DTE-DCE TransmissionSolutionFirstly the DTE-.pdf
PDF
Explain the data component of social media information systems (SMIS).pdf
PDF
Figure CWhich structure in the cell shown in Figure C above stores.pdf
PDF
Coral reefs. How sensitive to changes in water temperature are coral .pdf
PDF
•0.336 moles of a weak, monoproticacid added to a final volume of 2..pdf
PDF
You are to simulate a dispatcher using a priority queue system in C+.pdf
PDF
Write a program that accepts an arithmetic expression of unsigned in.pdf
PDF
Why was the knowledge of macromolecules “structure” very important i.pdf
PDF
Why did the sovereign debt problem of Greece a country that accounts.pdf
PDF
Which of the following could be the most likely cause of a superi.pdf
PDF
What is the theory of public debt managementSolution1. Sove.pdf
PDF
This is a three part question. For each part the answer requires ide.pdf
In a business projects What material is typically contained in a pro.pdf
Implement the following flowchart in java. Start Request integer k f.pdf
If no chiasma forms between homologous chromosomes, what happens Th.pdf
If two organims form a symbiotic realtionship where they share t.pdf
I would appreciate help with these 4 questions. Thank You.1) Expla.pdf
How do I know when to use the sin^2+cos^2=1 identity....12 angle id.pdf
I have a stack in Java populated with integers. Im trying to compa.pdf
Hint List of commands to read and use use of wild card characters .pdf
Explain in Detail DTE-DCE TransmissionSolutionFirstly the DTE-.pdf
Explain the data component of social media information systems (SMIS).pdf
Figure CWhich structure in the cell shown in Figure C above stores.pdf
Coral reefs. How sensitive to changes in water temperature are coral .pdf
•0.336 moles of a weak, monoproticacid added to a final volume of 2..pdf
You are to simulate a dispatcher using a priority queue system in C+.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
Why was the knowledge of macromolecules “structure” very important i.pdf
Why did the sovereign debt problem of Greece a country that accounts.pdf
Which of the following could be the most likely cause of a superi.pdf
What is the theory of public debt managementSolution1. Sove.pdf
This is a three part question. For each part the answer requires ide.pdf

Recently uploaded (20)

PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
1_English_Language_Set_2.pdf probationary
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Hazard Identification & Risk Assessment .pdf
PDF
advance database management system book.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PPTX
Cell Types and Its function , kingdom of life
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Trump Administration's workforce development strategy
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
RMMM.pdf make it easy to upload and study
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
Orientation - ARALprogram of Deped to the Parents.pptx
UNIT III MENTAL HEALTH NURSING ASSESSMENT
LDMMIA Reiki Yoga Finals Review Spring Summer
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Supply Chain Operations Speaking Notes -ICLT Program
1_English_Language_Set_2.pdf probationary
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Hazard Identification & Risk Assessment .pdf
advance database management system book.pdf
Classroom Observation Tools for Teachers
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Unit 4 Skeletal System.ppt.pptxopresentatiom
Cell Types and Its function , kingdom of life
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Trump Administration's workforce development strategy
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
RMMM.pdf make it easy to upload and study
Chinmaya Tiranga quiz Grand Finale.pdf

These are the 4 functions #include KiostreamP using namespac.pdf