Need help with c program at lines insert code using priority queue with output below #include #include

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Need help with c program at lines insert code using priority queue with output below #include #include

Post by answerhappygod »

Need help with c program at lines insert code using priorityqueue with output below
#include<stdio.h>#include<string.h>#include<stdlib.h>
typedef struct node{ char name[20]; int age; char address[100]; int reg; int priority; struct node *next;}node_t;
/* Inserting patients in the queue based on priority*/node_t *insert(struct node *front){
node_t *p,*temp;char name[20],address[100];temp=(node_t*)malloc(sizeof(node_t));printf("Enter patient Name:");scanf("%s", temp->name);printf("Enter the patient's age:");scanf("%d",&(temp->age));printf("Enter the address:");scanf("%s",temp->address);printf("Enter the reg no:");scanf("%d",&(temp->reg));printf("Enter the priority:");scanf("%d",&(temp->priority));int pri=temp->priority;
/*---insert your code here----*/}
/* Delete the patient who is at the front*/node_t *delete(struct node *front){ /*---insert your code here---*/}
/* To display the patients records */void display(node_t *front){node_t *temp=front;if(front==NULL) printf("\nTHERE IS NO PATIENT");else{printf("\nPatients waiting in the queue are:\n");while(temp!=NULL){printf("The name of patient is:%s\n",temp->name);printf("The age of patient is:%d\n",temp->age);printf("The address of patient is : %s\n",temp->address);printf("---------------------------------------------------\n");temp=temp->next;}}return;}/*---Deallocate all nodes------------*/void freenode(node_t *temp){if(temp!=NULL){freenode(temp->next);free(temp);}} /*-----------------Mainprogram---------------------------*/ int main() { node_t *front=NULL; int option; do{
printf("\t\t\tHospital emergency room system\n"); printf("\t\t\t1.ADD APATIENT\n"); printf("\t\t\t2.DELETE ARECORD\n"); printf("\t\t\t3.PATIENTSWAITING IN THE QUEUE\n"); printf("\t\t\tEnter yourchoice:"); scanf("%d",&option); switch(option) { /*Select 1 to insertelements in the priority queue*/ case 1: front=insert(front); break; /* Select 2 todelete the elements at the front of priority queue*/ case 2: front=delete(front); break; /* Select 3 To displaythe elements present in the priority queue*/ case 3: display(front); break;
} } while(option!=3); freenode(front); return 0;
}
Need Help With C Program At Lines Insert Code Using Priority Queue With Output Below Include Stdio H Include String H 1
Need Help With C Program At Lines Insert Code Using Priority Queue With Output Below Include Stdio H Include String H 1 (35.12 KiB) Viewed 38 times
Hospital emergency room system 1. ADD A PATIENT 2.DELETE A RECORD 3. PATIENTS WAITING IN THE QUEUE Enter your choice:2 Deleted Record is: 103 Patient's name is: Harry Patient's age: 34 Hospital emergency room system 1. ADD A PATIENT 2.DELETE A RECORD 3. PATIENTS WAITING IN THE QUEUE Enter your choice:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply