SlideShare a Scribd company logo
1 of 4
Download to read offline
Programming code in C ***************** must be C *****
loops requesting information about patients and inserting the information into a linked list:
call a function responsible for allocating the memory for the new item, requesting the following
information for each patient: first name, last name, and patientid (an integer), and putting the
information into the new item
the function mentioned in part a should return a pointer to the new item
call a function to insert the new item into the linked list
new patients should be added so that the list is in alphabetical order by the last name
leave the loop when the patient id is set to 0
displays the patient information in alphabetical order by the last name once all data has been
provided. The first and last name and patient id for each patient should be displayed
After the data has been input and displayed, enter another loop that asks for a patient’s last name
and then displays the information for that patient:
Write a function to search for the patient in the linked list and return a pointer to the item if it is
found. If it is not found return null
If the patient is found, display the patient’s full name and id number.
If the patient is not found, display a message saying the patient was not found.
Leave the loop if the person enters a zero for the person’s last name.
Solution
#include
#include
#include
//-------------------------------------------------
struct node
{
int pid;
char fname[10];
char sname[10];
struct node *next;
};
//------------------------------------------------------------
struct node *start=NULL;
struct node *create(struct node *);
struct node *display(struct node*);
struct node *sort(struct node*);
struct node *create(struct node *start)
{
struct node *new_node ,*ptr;
int num;
char ch;
do
{
new_node=(struct node *)malloc(sizeof(struct node));
printf("Enter Patient ID: ");
scanf("%d",&new_node->pid);
printf("Enter Patient First name: ");
scanf("%s",&new_node->fname);
printf("Enter Patient Second name: ");
scanf("%s",&new_node->sname);
new_node->next=NULL;
if(start==NULL)
{
new_node->next=NULL;
start=new_node;
}
else
{
ptr=start;
while(ptr->next!=NULL)
ptr=ptr->next;
ptr->next=new_node;
new_node->next=NULL;
}
printf(" Do you want to create another : ");
ch=getche();
}while(ch!='n');
return start;
}
//------------------------------------------------------------------
struct node* display(struct node* start)
{
struct node *new_node;
printf(" The Linked List : ");
new_node=start;
while(new_node!=NULL){
printf(" %d",new_node->pid);
printf("t%s", new_node->fname);
printf("t%s",new_node->sname);
new_node=new_node->next;
}
return start;
}
struct node* sort(struct node* start){
struct node *ptr1,*ptr2;
char temp[10];
int i;
while(ptr1->next!=NULL){
ptr2=ptr1->next;
while(ptr2!=NULL){
if(ptr1->sname[0]>ptr2->sname[0]){
for (i=0;i<2;i++)
temp[i]=ptr1->sname[i];
for (i=0;i<2;i++)
ptr1->sname[i]=ptr2->sname[i];
for (i=0;i<2;i++)
ptr2->sname[i]=temp[i];
}
ptr2=ptr2->next;
}
ptr1=ptr1->next;
}
return start;
}
//----------------------------------------------------
main()
{
start=create(start);
start=sort(start);
start=display(start);
getch();
}

More Related Content

Similar to Programming code in C must be C loops reque.pdf

Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfinfo114
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfsaradashata
 
linkedlistwith animations.ppt
linkedlistwith animations.pptlinkedlistwith animations.ppt
linkedlistwith animations.pptMuhammadShafi89
 
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.pdfadityastores21
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfaaseletronics2013
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdffortmdu
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfvishalateen
 
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 .pdfstopgolook
 
Arrays Fundamentals Unit II
Arrays  Fundamentals Unit IIArrays  Fundamentals Unit II
Arrays Fundamentals Unit IIArpana Awasthi
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Ritika sahu
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial        HS2021 Database Design and UseWeek 2 - 2020 Tutorial
HS2021 Database Design and UseWeek 2 - 2020 Tutorialtroutmanboris
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docxShiraPrater50
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdfalmaniaeyewear
 

Similar to Programming code in C must be C loops reque.pdf (17)

Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
 
linkedlistwith animations.ppt
linkedlistwith animations.pptlinkedlistwith animations.ppt
linkedlistwith animations.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
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
Linked list
Linked listLinked list
Linked list
 
JAVA Write a class called F.pdf
JAVA  Write a class called F.pdfJAVA  Write a class called F.pdf
JAVA Write a class called F.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
 
Arrays Fundamentals Unit II
Arrays  Fundamentals Unit IIArrays  Fundamentals Unit II
Arrays Fundamentals Unit II
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial        HS2021 Database Design and UseWeek 2 - 2020 Tutorial
HS2021 Database Design and UseWeek 2 - 2020 Tutorial
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 

More from archanadesignfashion

Blood typing is often used as evidence in paternity cases in court. .pdf
Blood typing is often used as evidence in paternity cases in court. .pdfBlood typing is often used as evidence in paternity cases in court. .pdf
Blood typing is often used as evidence in paternity cases in court. .pdfarchanadesignfashion
 
Write a very simple Note taking using JavaFX ( adding three function.pdf
Write a very simple Note taking using JavaFX ( adding three function.pdfWrite a very simple Note taking using JavaFX ( adding three function.pdf
Write a very simple Note taking using JavaFX ( adding three function.pdfarchanadesignfashion
 
Write a JAVA program that reads a stream of integers from a file and.pdf
Write a JAVA program that reads a stream of integers from a file and.pdfWrite a JAVA program that reads a stream of integers from a file and.pdf
Write a JAVA program that reads a stream of integers from a file and.pdfarchanadesignfashion
 
What two difficulties arise in taking simplicity straightforwardly a.pdf
What two difficulties arise in taking simplicity straightforwardly a.pdfWhat two difficulties arise in taking simplicity straightforwardly a.pdf
What two difficulties arise in taking simplicity straightforwardly a.pdfarchanadesignfashion
 
what is true about assetsSolutionAssets are those which are u.pdf
what is true about assetsSolutionAssets are those which are u.pdfwhat is true about assetsSolutionAssets are those which are u.pdf
what is true about assetsSolutionAssets are those which are u.pdfarchanadesignfashion
 
What happens if the dividing zygote accidental separates into two A.pdf
What happens if the dividing zygote accidental separates into two  A.pdfWhat happens if the dividing zygote accidental separates into two  A.pdf
What happens if the dividing zygote accidental separates into two A.pdfarchanadesignfashion
 
What are stored in the Autodesk Inventor History Tree When extrudin.pdf
What are stored in the Autodesk Inventor History Tree  When extrudin.pdfWhat are stored in the Autodesk Inventor History Tree  When extrudin.pdf
What are stored in the Autodesk Inventor History Tree When extrudin.pdfarchanadesignfashion
 
What are three factors contributing to resistanceCharacterize car.pdf
What are three factors contributing to resistanceCharacterize car.pdfWhat are three factors contributing to resistanceCharacterize car.pdf
What are three factors contributing to resistanceCharacterize car.pdfarchanadesignfashion
 
Alan Homes serves on the board of directors of Flynn Company. The pr.pdf
Alan Homes serves on the board of directors of Flynn Company. The pr.pdfAlan Homes serves on the board of directors of Flynn Company. The pr.pdf
Alan Homes serves on the board of directors of Flynn Company. The pr.pdfarchanadesignfashion
 
Two genes (A and B) are located 10cM apart on the X chromosome. A wom.pdf
Two genes (A and B) are located 10cM apart on the X chromosome. A wom.pdfTwo genes (A and B) are located 10cM apart on the X chromosome. A wom.pdf
Two genes (A and B) are located 10cM apart on the X chromosome. A wom.pdfarchanadesignfashion
 
q2.4) Listed are elements of the financial statements discussed in t.pdf
q2.4) Listed are elements of the financial statements discussed in t.pdfq2.4) Listed are elements of the financial statements discussed in t.pdf
q2.4) Listed are elements of the financial statements discussed in t.pdfarchanadesignfashion
 
Please find the solution. Thanks 4. As the value of increases fro.pdf
Please find the solution. Thanks 4. As the value of increases fro.pdfPlease find the solution. Thanks 4. As the value of increases fro.pdf
Please find the solution. Thanks 4. As the value of increases fro.pdfarchanadesignfashion
 
Please help! Both answers must be in long paragraph form1. Explain.pdf
Please help! Both answers must be in long paragraph form1. Explain.pdfPlease help! Both answers must be in long paragraph form1. Explain.pdf
Please help! Both answers must be in long paragraph form1. Explain.pdfarchanadesignfashion
 
Life is easy to recognize but difficult to define. According to .pdf
Life is easy to recognize but difficult to define. According to .pdfLife is easy to recognize but difficult to define. According to .pdf
Life is easy to recognize but difficult to define. According to .pdfarchanadesignfashion
 
Let I, J be ideals in a ring R. Prove that I J is also an ideal of R.pdf
Let I, J be ideals in a ring R. Prove that I  J is also an ideal of R.pdfLet I, J be ideals in a ring R. Prove that I  J is also an ideal of R.pdf
Let I, J be ideals in a ring R. Prove that I J is also an ideal of R.pdfarchanadesignfashion
 
Imagine that one of the segments in Drosophila is T2, which will for.pdf
Imagine that one of the segments in Drosophila is T2, which will for.pdfImagine that one of the segments in Drosophila is T2, which will for.pdf
Imagine that one of the segments in Drosophila is T2, which will for.pdfarchanadesignfashion
 
If the Social Security retirement system was a private retirement sy.pdf
If the Social Security retirement system was a private retirement sy.pdfIf the Social Security retirement system was a private retirement sy.pdf
If the Social Security retirement system was a private retirement sy.pdfarchanadesignfashion
 
Identify the following reaction Glucose + Fructose rightarrow Sucros.pdf
Identify the following reaction Glucose + Fructose rightarrow Sucros.pdfIdentify the following reaction Glucose + Fructose rightarrow Sucros.pdf
Identify the following reaction Glucose + Fructose rightarrow Sucros.pdfarchanadesignfashion
 
identify the developmental genes that influence macroevolutionSo.pdf
identify the developmental genes that influence macroevolutionSo.pdfidentify the developmental genes that influence macroevolutionSo.pdf
identify the developmental genes that influence macroevolutionSo.pdfarchanadesignfashion
 
I need answer to those questions please ASAP Im stuck D Question 1.pdf
I need answer to those questions please ASAP Im stuck D Question 1.pdfI need answer to those questions please ASAP Im stuck D Question 1.pdf
I need answer to those questions please ASAP Im stuck D Question 1.pdfarchanadesignfashion
 

More from archanadesignfashion (20)

Blood typing is often used as evidence in paternity cases in court. .pdf
Blood typing is often used as evidence in paternity cases in court. .pdfBlood typing is often used as evidence in paternity cases in court. .pdf
Blood typing is often used as evidence in paternity cases in court. .pdf
 
Write a very simple Note taking using JavaFX ( adding three function.pdf
Write a very simple Note taking using JavaFX ( adding three function.pdfWrite a very simple Note taking using JavaFX ( adding three function.pdf
Write a very simple Note taking using JavaFX ( adding three function.pdf
 
Write a JAVA program that reads a stream of integers from a file and.pdf
Write a JAVA program that reads a stream of integers from a file and.pdfWrite a JAVA program that reads a stream of integers from a file and.pdf
Write a JAVA program that reads a stream of integers from a file and.pdf
 
What two difficulties arise in taking simplicity straightforwardly a.pdf
What two difficulties arise in taking simplicity straightforwardly a.pdfWhat two difficulties arise in taking simplicity straightforwardly a.pdf
What two difficulties arise in taking simplicity straightforwardly a.pdf
 
what is true about assetsSolutionAssets are those which are u.pdf
what is true about assetsSolutionAssets are those which are u.pdfwhat is true about assetsSolutionAssets are those which are u.pdf
what is true about assetsSolutionAssets are those which are u.pdf
 
What happens if the dividing zygote accidental separates into two A.pdf
What happens if the dividing zygote accidental separates into two  A.pdfWhat happens if the dividing zygote accidental separates into two  A.pdf
What happens if the dividing zygote accidental separates into two A.pdf
 
What are stored in the Autodesk Inventor History Tree When extrudin.pdf
What are stored in the Autodesk Inventor History Tree  When extrudin.pdfWhat are stored in the Autodesk Inventor History Tree  When extrudin.pdf
What are stored in the Autodesk Inventor History Tree When extrudin.pdf
 
What are three factors contributing to resistanceCharacterize car.pdf
What are three factors contributing to resistanceCharacterize car.pdfWhat are three factors contributing to resistanceCharacterize car.pdf
What are three factors contributing to resistanceCharacterize car.pdf
 
Alan Homes serves on the board of directors of Flynn Company. The pr.pdf
Alan Homes serves on the board of directors of Flynn Company. The pr.pdfAlan Homes serves on the board of directors of Flynn Company. The pr.pdf
Alan Homes serves on the board of directors of Flynn Company. The pr.pdf
 
Two genes (A and B) are located 10cM apart on the X chromosome. A wom.pdf
Two genes (A and B) are located 10cM apart on the X chromosome. A wom.pdfTwo genes (A and B) are located 10cM apart on the X chromosome. A wom.pdf
Two genes (A and B) are located 10cM apart on the X chromosome. A wom.pdf
 
q2.4) Listed are elements of the financial statements discussed in t.pdf
q2.4) Listed are elements of the financial statements discussed in t.pdfq2.4) Listed are elements of the financial statements discussed in t.pdf
q2.4) Listed are elements of the financial statements discussed in t.pdf
 
Please find the solution. Thanks 4. As the value of increases fro.pdf
Please find the solution. Thanks 4. As the value of increases fro.pdfPlease find the solution. Thanks 4. As the value of increases fro.pdf
Please find the solution. Thanks 4. As the value of increases fro.pdf
 
Please help! Both answers must be in long paragraph form1. Explain.pdf
Please help! Both answers must be in long paragraph form1. Explain.pdfPlease help! Both answers must be in long paragraph form1. Explain.pdf
Please help! Both answers must be in long paragraph form1. Explain.pdf
 
Life is easy to recognize but difficult to define. According to .pdf
Life is easy to recognize but difficult to define. According to .pdfLife is easy to recognize but difficult to define. According to .pdf
Life is easy to recognize but difficult to define. According to .pdf
 
Let I, J be ideals in a ring R. Prove that I J is also an ideal of R.pdf
Let I, J be ideals in a ring R. Prove that I  J is also an ideal of R.pdfLet I, J be ideals in a ring R. Prove that I  J is also an ideal of R.pdf
Let I, J be ideals in a ring R. Prove that I J is also an ideal of R.pdf
 
Imagine that one of the segments in Drosophila is T2, which will for.pdf
Imagine that one of the segments in Drosophila is T2, which will for.pdfImagine that one of the segments in Drosophila is T2, which will for.pdf
Imagine that one of the segments in Drosophila is T2, which will for.pdf
 
If the Social Security retirement system was a private retirement sy.pdf
If the Social Security retirement system was a private retirement sy.pdfIf the Social Security retirement system was a private retirement sy.pdf
If the Social Security retirement system was a private retirement sy.pdf
 
Identify the following reaction Glucose + Fructose rightarrow Sucros.pdf
Identify the following reaction Glucose + Fructose rightarrow Sucros.pdfIdentify the following reaction Glucose + Fructose rightarrow Sucros.pdf
Identify the following reaction Glucose + Fructose rightarrow Sucros.pdf
 
identify the developmental genes that influence macroevolutionSo.pdf
identify the developmental genes that influence macroevolutionSo.pdfidentify the developmental genes that influence macroevolutionSo.pdf
identify the developmental genes that influence macroevolutionSo.pdf
 
I need answer to those questions please ASAP Im stuck D Question 1.pdf
I need answer to those questions please ASAP Im stuck D Question 1.pdfI need answer to those questions please ASAP Im stuck D Question 1.pdf
I need answer to those questions please ASAP Im stuck D Question 1.pdf
 

Recently uploaded

Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 

Recently uploaded (20)

Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 

Programming code in C must be C loops reque.pdf

  • 1. Programming code in C ***************** must be C ***** loops requesting information about patients and inserting the information into a linked list: call a function responsible for allocating the memory for the new item, requesting the following information for each patient: first name, last name, and patientid (an integer), and putting the information into the new item the function mentioned in part a should return a pointer to the new item call a function to insert the new item into the linked list new patients should be added so that the list is in alphabetical order by the last name leave the loop when the patient id is set to 0 displays the patient information in alphabetical order by the last name once all data has been provided. The first and last name and patient id for each patient should be displayed After the data has been input and displayed, enter another loop that asks for a patient’s last name and then displays the information for that patient: Write a function to search for the patient in the linked list and return a pointer to the item if it is found. If it is not found return null If the patient is found, display the patient’s full name and id number. If the patient is not found, display a message saying the patient was not found. Leave the loop if the person enters a zero for the person’s last name. Solution #include #include #include //------------------------------------------------- struct node { int pid; char fname[10]; char sname[10]; struct node *next; }; //------------------------------------------------------------ struct node *start=NULL; struct node *create(struct node *);
  • 2. struct node *display(struct node*); struct node *sort(struct node*); struct node *create(struct node *start) { struct node *new_node ,*ptr; int num; char ch; do { new_node=(struct node *)malloc(sizeof(struct node)); printf("Enter Patient ID: "); scanf("%d",&new_node->pid); printf("Enter Patient First name: "); scanf("%s",&new_node->fname); printf("Enter Patient Second name: "); scanf("%s",&new_node->sname); new_node->next=NULL; if(start==NULL) { new_node->next=NULL; start=new_node; } else { ptr=start; while(ptr->next!=NULL) ptr=ptr->next; ptr->next=new_node; new_node->next=NULL; } printf(" Do you want to create another : "); ch=getche(); }while(ch!='n'); return start; } //------------------------------------------------------------------
  • 3. struct node* display(struct node* start) { struct node *new_node; printf(" The Linked List : "); new_node=start; while(new_node!=NULL){ printf(" %d",new_node->pid); printf("t%s", new_node->fname); printf("t%s",new_node->sname); new_node=new_node->next; } return start; } struct node* sort(struct node* start){ struct node *ptr1,*ptr2; char temp[10]; int i; while(ptr1->next!=NULL){ ptr2=ptr1->next; while(ptr2!=NULL){ if(ptr1->sname[0]>ptr2->sname[0]){ for (i=0;i<2;i++) temp[i]=ptr1->sname[i]; for (i=0;i<2;i++) ptr1->sname[i]=ptr2->sname[i]; for (i=0;i<2;i++) ptr2->sname[i]=temp[i]; } ptr2=ptr2->next; } ptr1=ptr1->next; } return start; } //----------------------------------------------------