Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The attached data file ‘donors.dat’ stores blood donor information for a biomedi

ID: 3768957 • Letter: T

Question

The attached data file ‘donors.dat’ stores blood donor information for a biomedical research company. Open and read the data file and understand its format. For every donor, it stores the person’s name, blood pressure, blood type, and Rh factor information. The Blood type is either A, B, AB, or O. The Rh factor is + or .

Write a function that takes one input argument: the blood type in the format of a string (A, B, AB, or O). The function will display the names of all donors with the same blood type as the input argument. Hint: the function should read from your file into a data structure; then search through all donors for the given blood type. As an example:

>> FindDonors('AB')

George Aaron

Doug Smith

(donors.dat) data:

First Last Systolic Diastolic BloodType Rh Donald Bird 120.1 78.2 A + George Aaron 111.1 70.3 AB - Claire Stuart 108.1 65.3 O - Jan Doe 102.3 63.2 B + Doug Smith 110.5 66.3 AB + Smith Jane 135.2 83.2 B - Pat Mozart 132.1 81.5 O + Curt Polaris 122.8 79.6 A -

Explanation / Answer

#include<stdio.h>
#include<conio.h>
void main() {

FILE *fp;
char another='y';
char i;
int line=1;

clrscr();

fp=fopen("DONORS.DAT","r");

if(fp==NULL) {

printf(" Cannot open file!");

delay(1000);
exit();
}
struct blood {
   char name[50];
   char adr[50];
   int age;
   int bld;
   } b;

clrscr();

fp=fopen("DONORS.DAT","wb");

if(fp==NULL) {
printf("cannot open target file! ");
exit();
}

while(another=='Y' || another=='y') {

clrscr();
printf(" Information of Blood donor ");
printf(" ************************** ");
printf("Enter the name: ");
scanf("%s",b.name);
printf(" enter the address: ");
scanf("%s",b.adr);
printf(" enter the age: ");
scanf("%d",&b.age);
printf(" enter the blood group(1/2/3/4): ");
scanf("%d",&b.bld);

fprintf(fp,"%s %s %d %d",b.name,b.adr,b.age,b.bld);

printf(" enter more information(Y/N): ");
fflush(stdin);

another=getch();

}

fclose(fp);

}

Program to read record file for specifications


/* This program will read the information from the file made by writing program */

           /* Reading Program */

#include<stdio.h>
#include<conio.h>
void main() {

FILE *fp;
char ch;

struct blood {
       char name[50];
       char adr[50];
       int age;
       int bld;
       }b;
clrscr();

fp=fopen("BLOODBANK.DAT","rb");

if(fp==NULL) {
printf("cannot open source file! ");
exit();
}

while(fscanf(fp,"%s %s %d %d",&b.name,&b.adr,&b.age,&b.bld)!=EOF)
if(b.age<25 && b.bld==2) {
printf(" %s %s %2d %d",b.name,b.adr,b.age,b.bld);
}
fclose(fp);

getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote