SlideShare a Scribd company logo
#include
#include
#include
#define MAX_STR_LEN 80
//decalring the structure
struct link_node
{
//declaring the variables
char node_str[ MAX_STR_LEN ];
struct link_node *next;
};
//method declaration
typedef struct link_node link_node;
struct link_node *add_node( struct link_node *list,struct link_node *node );
int compare_node( struct link_node *n1, struct link_node *n2 );
void display_list( struct link_node *head );
//implementing the method main
int main()
{
//declaring the main variables
link_node * head=NULL,*temp;
char str[MAX_STR_LEN];
do
{
//getting the STRING input
printf("Enter the string : ");
gets(str);
//malloc() is implemented for memory
temp=(link_node*)malloc(sizeof(link_node));
temp->next=NULL;
strcpy(temp->node_str,str);
head=add_node(head,temp);
}while(strlen(str)>1);
display_list(head);
return 0;
}
//method definition for compare node
int compare_node( struct link_node *n1, struct link_node *n2 )
{
if(strcmp(n1->node_str,n2->node_str)==0)
return 0;
if(strcmp(n1->node_str,n2->node_str)<0)
return -1;
else
return 1;
}
//method definition for adding the node
struct link_node *add_node( struct link_node *list,struct link_node *node )
{
link_node *temp=list;
if(list==NULL)
{
return node;
}
if(compare_node(node,list)==-1)
{
node->next=list;
list=node;
return list;
}
else
{
link_node *prev=list;
while(temp!=NULL&&compare_node(node,temp)>=0)
{
prev=temp;
temp=temp->next;
}
prev->next=node;
node->next=temp;
return list;
}
}
//method definition for displaying the list
void display_list( struct link_node *head )
{
link_node *temp;
while(head)
{
printf("%s ",head->node_str);
temp=head;
head=head->next;
free(temp);
}
}
Sample output:
Enter the string:
Geneva
America
Solution
#include
#include
#include
#define MAX_STR_LEN 80
//decalring the structure
struct link_node
{
//declaring the variables
char node_str[ MAX_STR_LEN ];
struct link_node *next;
};
//method declaration
typedef struct link_node link_node;
struct link_node *add_node( struct link_node *list,struct link_node *node );
int compare_node( struct link_node *n1, struct link_node *n2 );
void display_list( struct link_node *head );
//implementing the method main
int main()
{
//declaring the main variables
link_node * head=NULL,*temp;
char str[MAX_STR_LEN];
do
{
//getting the STRING input
printf("Enter the string : ");
gets(str);
//malloc() is implemented for memory
temp=(link_node*)malloc(sizeof(link_node));
temp->next=NULL;
strcpy(temp->node_str,str);
head=add_node(head,temp);
}while(strlen(str)>1);
display_list(head);
return 0;
}
//method definition for compare node
int compare_node( struct link_node *n1, struct link_node *n2 )
{
if(strcmp(n1->node_str,n2->node_str)==0)
return 0;
if(strcmp(n1->node_str,n2->node_str)<0)
return -1;
else
return 1;
}
//method definition for adding the node
struct link_node *add_node( struct link_node *list,struct link_node *node )
{
link_node *temp=list;
if(list==NULL)
{
return node;
}
if(compare_node(node,list)==-1)
{
node->next=list;
list=node;
return list;
}
else
{
link_node *prev=list;
while(temp!=NULL&&compare_node(node,temp)>=0)
{
prev=temp;
temp=temp->next;
}
prev->next=node;
node->next=temp;
return list;
}
}
//method definition for displaying the list
void display_list( struct link_node *head )
{
link_node *temp;
while(head)
{
printf("%s ",head->node_str);
temp=head;
head=head->next;
free(temp);
}
}
Sample output:
Enter the string:
Geneva
America

More Related Content

Similar to #includestdio.h#includestring.h#includestdlib.h#define M.pdf

Easy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdfEasy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
sudhakargeruganti
 
Create a JAVA program that performs file IO and database interaction.pdf
Create a JAVA program that performs file IO and database interaction.pdfCreate a JAVA program that performs file IO and database interaction.pdf
Create a JAVA program that performs file IO and database interaction.pdf
malavshah9013
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
KamalSaini561034
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
deepua8
 
srgoc
srgocsrgoc
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
DS UNIT3_LINKED LISTS.docx
DS UNIT3_LINKED LISTS.docxDS UNIT3_LINKED LISTS.docx
DS UNIT3_LINKED LISTS.docx
VeerannaKotagi1
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
anton291
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
sales87
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
naslin841216
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad baloch
Sarmad Baloch
 
So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
leolight2
 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdf
stopgolook
 
structure.ppt
structure.pptstructure.ppt
structure.ppt
Sheik Mohideen
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
adityastores21
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
Shakila Mahjabin
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
arshiartpalace
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
fathimafancyjeweller
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 

Similar to #includestdio.h#includestring.h#includestdlib.h#define M.pdf (20)

Easy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdfEasy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
 
Create a JAVA program that performs file IO and database interaction.pdf
Create a JAVA program that performs file IO and database interaction.pdfCreate a JAVA program that performs file IO and database interaction.pdf
Create a JAVA program that performs file IO and database interaction.pdf
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
 
srgoc
srgocsrgoc
srgoc
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
DS UNIT3_LINKED LISTS.docx
DS UNIT3_LINKED LISTS.docxDS UNIT3_LINKED LISTS.docx
DS UNIT3_LINKED LISTS.docx
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad baloch
 
So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdf
 
structure.ppt
structure.pptstructure.ppt
structure.ppt
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
 

More from ANJALIENTERPRISES1

H2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdf
H2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdfH2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdf
H2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdf
ANJALIENTERPRISES1
 
Computer graphics are pictures and movies produced use computers fre.pdf
Computer graphics are pictures and movies produced use computers fre.pdfComputer graphics are pictures and movies produced use computers fre.pdf
Computer graphics are pictures and movies produced use computers fre.pdf
ANJALIENTERPRISES1
 
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfCircle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
ANJALIENTERPRISES1
 
C is correct. Only the host that the unicast message is addressed to.pdf
C is correct. Only the host that the unicast message is addressed to.pdfC is correct. Only the host that the unicast message is addressed to.pdf
C is correct. Only the host that the unicast message is addressed to.pdf
ANJALIENTERPRISES1
 
According to the seriousness level, the following organs areThymu.pdf
According to the seriousness level, the following organs areThymu.pdfAccording to the seriousness level, the following organs areThymu.pdf
According to the seriousness level, the following organs areThymu.pdf
ANJALIENTERPRISES1
 
Among 40 subjects randomly choose 20 subjects and assign themSol.pdf
Among 40 subjects randomly choose 20 subjects and assign themSol.pdfAmong 40 subjects randomly choose 20 subjects and assign themSol.pdf
Among 40 subjects randomly choose 20 subjects and assign themSol.pdf
ANJALIENTERPRISES1
 
AdvantagesThe main objective of business combination is to elimina.pdf
AdvantagesThe main objective of business combination is to elimina.pdfAdvantagesThe main objective of business combination is to elimina.pdf
AdvantagesThe main objective of business combination is to elimina.pdf
ANJALIENTERPRISES1
 
a. Germ cell speciication in Drosophila is primarily a maternlly con.pdf
a. Germ cell speciication in Drosophila is primarily a maternlly con.pdfa. Germ cell speciication in Drosophila is primarily a maternlly con.pdf
a. Germ cell speciication in Drosophila is primarily a maternlly con.pdf
ANJALIENTERPRISES1
 
A is correct. The packets to be filtered would be heading into the r.pdf
A is correct. The packets to be filtered would be heading into the r.pdfA is correct. The packets to be filtered would be heading into the r.pdf
A is correct. The packets to be filtered would be heading into the r.pdf
ANJALIENTERPRISES1
 
1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf
1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf
1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf
ANJALIENTERPRISES1
 
-FSolution-F.pdf
-FSolution-F.pdf-FSolution-F.pdf
-FSolution-F.pdf
ANJALIENTERPRISES1
 
17-The Y-Chromosome DNA testing helps in the examination of the male.pdf
17-The Y-Chromosome DNA testing helps in the examination of the male.pdf17-The Y-Chromosome DNA testing helps in the examination of the male.pdf
17-The Y-Chromosome DNA testing helps in the examination of the male.pdf
ANJALIENTERPRISES1
 
The pH and pOH of a solution are defined as pH .pdf
                     The pH and pOH of a solution are defined as  pH .pdf                     The pH and pOH of a solution are defined as  pH .pdf
The pH and pOH of a solution are defined as pH .pdf
ANJALIENTERPRISES1
 
goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf
  goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf  goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf
goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf
ANJALIENTERPRISES1
 
7 steps are required as 9 is the 7th element and the search is line.pdf
 7 steps are required as 9 is the 7th element and the search is line.pdf 7 steps are required as 9 is the 7th element and the search is line.pdf
7 steps are required as 9 is the 7th element and the search is line.pdf
ANJALIENTERPRISES1
 
(D) the number of moles of hydroxide ion added and the number of mol.pdf
  (D) the number of moles of hydroxide ion added and the number of mol.pdf  (D) the number of moles of hydroxide ion added and the number of mol.pdf
(D) the number of moles of hydroxide ion added and the number of mol.pdf
ANJALIENTERPRISES1
 
Look for changes in oxidation numbers. These occ.pdf
                     Look for changes in oxidation numbers.  These occ.pdf                     Look for changes in oxidation numbers.  These occ.pdf
Look for changes in oxidation numbers. These occ.pdf
ANJALIENTERPRISES1
 
D) Insulin .pdf
                     D) Insulin                                       .pdf                     D) Insulin                                       .pdf
D) Insulin .pdf
ANJALIENTERPRISES1
 
Use Daltons Law of partial pressures. P(Total).pdf
                     Use Daltons Law of partial pressures.  P(Total).pdf                     Use Daltons Law of partial pressures.  P(Total).pdf
Use Daltons Law of partial pressures. P(Total).pdf
ANJALIENTERPRISES1
 
The Br was originally neutral, but picks up an ex.pdf
                     The Br was originally neutral, but picks up an ex.pdf                     The Br was originally neutral, but picks up an ex.pdf
The Br was originally neutral, but picks up an ex.pdf
ANJALIENTERPRISES1
 

More from ANJALIENTERPRISES1 (20)

H2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdf
H2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdfH2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdf
H2SO4 may act as 1) an acidexample 2NaOH + H2SO4 - Na2SO4 +.pdf
 
Computer graphics are pictures and movies produced use computers fre.pdf
Computer graphics are pictures and movies produced use computers fre.pdfComputer graphics are pictures and movies produced use computers fre.pdf
Computer graphics are pictures and movies produced use computers fre.pdf
 
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfCircle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
 
C is correct. Only the host that the unicast message is addressed to.pdf
C is correct. Only the host that the unicast message is addressed to.pdfC is correct. Only the host that the unicast message is addressed to.pdf
C is correct. Only the host that the unicast message is addressed to.pdf
 
According to the seriousness level, the following organs areThymu.pdf
According to the seriousness level, the following organs areThymu.pdfAccording to the seriousness level, the following organs areThymu.pdf
According to the seriousness level, the following organs areThymu.pdf
 
Among 40 subjects randomly choose 20 subjects and assign themSol.pdf
Among 40 subjects randomly choose 20 subjects and assign themSol.pdfAmong 40 subjects randomly choose 20 subjects and assign themSol.pdf
Among 40 subjects randomly choose 20 subjects and assign themSol.pdf
 
AdvantagesThe main objective of business combination is to elimina.pdf
AdvantagesThe main objective of business combination is to elimina.pdfAdvantagesThe main objective of business combination is to elimina.pdf
AdvantagesThe main objective of business combination is to elimina.pdf
 
a. Germ cell speciication in Drosophila is primarily a maternlly con.pdf
a. Germ cell speciication in Drosophila is primarily a maternlly con.pdfa. Germ cell speciication in Drosophila is primarily a maternlly con.pdf
a. Germ cell speciication in Drosophila is primarily a maternlly con.pdf
 
A is correct. The packets to be filtered would be heading into the r.pdf
A is correct. The packets to be filtered would be heading into the r.pdfA is correct. The packets to be filtered would be heading into the r.pdf
A is correct. The packets to be filtered would be heading into the r.pdf
 
1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf
1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf
1). A) ipsilateralBelow the point of spinal cord, the nerve paths .pdf
 
-FSolution-F.pdf
-FSolution-F.pdf-FSolution-F.pdf
-FSolution-F.pdf
 
17-The Y-Chromosome DNA testing helps in the examination of the male.pdf
17-The Y-Chromosome DNA testing helps in the examination of the male.pdf17-The Y-Chromosome DNA testing helps in the examination of the male.pdf
17-The Y-Chromosome DNA testing helps in the examination of the male.pdf
 
The pH and pOH of a solution are defined as pH .pdf
                     The pH and pOH of a solution are defined as  pH .pdf                     The pH and pOH of a solution are defined as  pH .pdf
The pH and pOH of a solution are defined as pH .pdf
 
goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf
  goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf  goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf
goal_state = [1, 8, 7, 2, 0, 6, 3, 4, 5] #goal_state = [1, 0, 7, 2, .pdf
 
7 steps are required as 9 is the 7th element and the search is line.pdf
 7 steps are required as 9 is the 7th element and the search is line.pdf 7 steps are required as 9 is the 7th element and the search is line.pdf
7 steps are required as 9 is the 7th element and the search is line.pdf
 
(D) the number of moles of hydroxide ion added and the number of mol.pdf
  (D) the number of moles of hydroxide ion added and the number of mol.pdf  (D) the number of moles of hydroxide ion added and the number of mol.pdf
(D) the number of moles of hydroxide ion added and the number of mol.pdf
 
Look for changes in oxidation numbers. These occ.pdf
                     Look for changes in oxidation numbers.  These occ.pdf                     Look for changes in oxidation numbers.  These occ.pdf
Look for changes in oxidation numbers. These occ.pdf
 
D) Insulin .pdf
                     D) Insulin                                       .pdf                     D) Insulin                                       .pdf
D) Insulin .pdf
 
Use Daltons Law of partial pressures. P(Total).pdf
                     Use Daltons Law of partial pressures.  P(Total).pdf                     Use Daltons Law of partial pressures.  P(Total).pdf
Use Daltons Law of partial pressures. P(Total).pdf
 
The Br was originally neutral, but picks up an ex.pdf
                     The Br was originally neutral, but picks up an ex.pdf                     The Br was originally neutral, but picks up an ex.pdf
The Br was originally neutral, but picks up an ex.pdf
 

Recently uploaded

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
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
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
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
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
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
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
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.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
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
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.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
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 

#includestdio.h#includestring.h#includestdlib.h#define M.pdf

  • 1. #include #include #include #define MAX_STR_LEN 80 //decalring the structure struct link_node { //declaring the variables char node_str[ MAX_STR_LEN ]; struct link_node *next; }; //method declaration typedef struct link_node link_node; struct link_node *add_node( struct link_node *list,struct link_node *node ); int compare_node( struct link_node *n1, struct link_node *n2 ); void display_list( struct link_node *head ); //implementing the method main int main() { //declaring the main variables link_node * head=NULL,*temp; char str[MAX_STR_LEN]; do { //getting the STRING input printf("Enter the string : "); gets(str); //malloc() is implemented for memory temp=(link_node*)malloc(sizeof(link_node)); temp->next=NULL; strcpy(temp->node_str,str); head=add_node(head,temp); }while(strlen(str)>1); display_list(head); return 0;
  • 2. } //method definition for compare node int compare_node( struct link_node *n1, struct link_node *n2 ) { if(strcmp(n1->node_str,n2->node_str)==0) return 0; if(strcmp(n1->node_str,n2->node_str)<0) return -1; else return 1; } //method definition for adding the node struct link_node *add_node( struct link_node *list,struct link_node *node ) { link_node *temp=list; if(list==NULL) { return node; } if(compare_node(node,list)==-1) { node->next=list; list=node; return list; } else { link_node *prev=list; while(temp!=NULL&&compare_node(node,temp)>=0) { prev=temp; temp=temp->next; } prev->next=node; node->next=temp; return list;
  • 3. } } //method definition for displaying the list void display_list( struct link_node *head ) { link_node *temp; while(head) { printf("%s ",head->node_str); temp=head; head=head->next; free(temp); } } Sample output: Enter the string: Geneva America Solution #include #include #include #define MAX_STR_LEN 80 //decalring the structure struct link_node { //declaring the variables char node_str[ MAX_STR_LEN ]; struct link_node *next; }; //method declaration typedef struct link_node link_node; struct link_node *add_node( struct link_node *list,struct link_node *node ); int compare_node( struct link_node *n1, struct link_node *n2 );
  • 4. void display_list( struct link_node *head ); //implementing the method main int main() { //declaring the main variables link_node * head=NULL,*temp; char str[MAX_STR_LEN]; do { //getting the STRING input printf("Enter the string : "); gets(str); //malloc() is implemented for memory temp=(link_node*)malloc(sizeof(link_node)); temp->next=NULL; strcpy(temp->node_str,str); head=add_node(head,temp); }while(strlen(str)>1); display_list(head); return 0; } //method definition for compare node int compare_node( struct link_node *n1, struct link_node *n2 ) { if(strcmp(n1->node_str,n2->node_str)==0) return 0; if(strcmp(n1->node_str,n2->node_str)<0) return -1; else return 1; } //method definition for adding the node struct link_node *add_node( struct link_node *list,struct link_node *node ) { link_node *temp=list; if(list==NULL)
  • 5. { return node; } if(compare_node(node,list)==-1) { node->next=list; list=node; return list; } else { link_node *prev=list; while(temp!=NULL&&compare_node(node,temp)>=0) { prev=temp; temp=temp->next; } prev->next=node; node->next=temp; return list; } } //method definition for displaying the list void display_list( struct link_node *head ) { link_node *temp; while(head) { printf("%s ",head->node_str); temp=head; head=head->next; free(temp); } } Sample output: Enter the string: