1
12kviews
Write a C program which will print the list of all patients with given disease.

A Hospital needs to maintain details of patients. Details to be maintained are: First name, Middle name, Surname, Date of Birth, Disease.

Mumbai university > FE > SEM 2 > Structured Programming Approach

Marks: 10M

Year: May 2014

1 Answer
0
684views

Program code:

#include<stdio.h>
#include<conio.h>
struct patient{
int dob;
char Fname[10], Mname[10], Lname[10], disease[10];
} pt[10] ;
int main(){
int i, n ;

printf("Enter the Number of Patients: ");
scanf("%d", &n) ;

for(i = 0 ; i < n ; i++) {
printf("\t\t\tPatient's Details:\n");
printf("\nEnter the Patients DOB: ");
scanf("%d", &pt[i].dob);
printf("\nEnter the First Name: ");
scanf("%s", pt[i].Fname);
printf("\nEnter the Middle Name: ");
scanf("%s", pt[i].Mname);
printf("\nEnter the Last Name: ");
scanf("%s", pt[i].Lname);
printf("\nEnter the Disease Name: ");
scanf("%s", pt[i].disease);
}

printf("\nDOB \t First Name \t Middle Name \t Last Name \t Disease \n\n");

for(i = 0 ; i < n ; i++){
printf("%d \t %s \t %s \t %s \t %s \n", pt[i].dob, pt[i].Fname, pt[i].Mname, pt[i].Lname, pt[i].disease);
}
getch();
}

Output:

Enter the Number of Patients: 3

Patient's Details:

Enter the Patients DOB: 09-03-1994
Enter the First Name: VAN   
Enter the Middle Name: DER
Enter the Last Name: VART
Enter the Disease Name: MALARIA

Patient's Details:

Enter the Patients DOB: 17-09-1994
Enter the First Name: DAVID
Enter the Middle Name: PHILIP
Enter the Last Name: :LUIZ
Enter the Disease Name: JAUNDICE

Patient's Details:

Enter the Patients DOB: 11-09-1997
Enter the First Name: ROBIN
Enter the Middle Name: VAN
Enter the Last Name: PERSIE
Enter the Disease Name: MALARIA
Please log in to add an answer.