Design a C program for consulting a doctor in a clinic on priority basis. (Get patient Name and assign priority for them. Those who are having higher

Leave a Comment
#include<stdio.h>
#include<stdlib.h>

#include<conio.h>

struct doc{
char name[100];
int prior;
}a[100];
int n,front=-1,rear=-1;
int isempty()
{
if(front==-1||front>rear)
return 1;
else
return 0;
}
int isfull()
{
if(rear==n-1)
return 1;
else
return 0;
}
 

void insert()
{
int j;
struct doc t;
if(!isfull())
{
printf("\nEnter the patient name:");
scanf("%s",t.name);
printf("\nNow assign a priority number(1>2):");
scanf("%d",&t.prior);

if(front==-1)
front++;
j=rear;
while(j>=0&&(t.prior))

 {
a[j+1]=a[j];
j--;
}
a[j+1]=t;
rear++;
}
else
printf("\nThe list is already full!!!");
}
void print()
{
if(!isempty())
{
printf("\nPatient name:%s",a[front].name);
front++;
}
else
printf("\nThe list is already over!!!");
}
int main()
{
printf("\nEnter the maximum limit:");
scanf("%d",&n);
int o;
while(o!=0)
{
printf("\nMENU\n");
printf("\nEnter 1 for inserting doctor job");
printf("\nEnter 2 for getting the patient job");
printf("\nEnter 3 for checking the job list is full or not??");
printf("\nEnter 4 for checking the job list is empty or not??");
printf("\nEnter 0 for exit!");
printf("\nEnter the choice:");
scanf("%d",&o);
switch(o)
{
case 1:insert();break;
case 2:print();break;
case 4:{if(isempty()==1)
printf("\nThe job lict is empty!!!");
else
printf("\nThe job list is not empty!!");
break;
}
case 3:{if(isfull()==1)
printf("\nThe job lict is full!!!");
else
printf("\nThe job list is not full!!");
break;
}
case 0:exit(0);break;
default:printf("\nYou have entered the wrong choice!!!");
}
}
getche();
}

0 comments: