Could someone please look at this and tell me why it won't run?
Code:
#include <stdio.h>
#include <stdlib.h>
struct patient
{
char id [20];
int systolic;
int diastolic;
int ldl;
int hdl;
};
void main()
{
int cholesterol_level;
int i;
struct patient a[4];
for (i=0; i<=3; i++)
{
printf("Please enter patient ID number \n");
if(i!=0)
scanf("\n"); /*Clears memory buffer*/
gets (a[i].id);
printf("Please enter systolic blood pressure \n");
scanf ("%d", a[i].systolic);
printf("Please enter diastolic blood pressure \n");
scanf ("%d", a[i].diastolic);
printf ("Please enter ldl cholesterol \n");
scanf ("%d", a[i].ldl);
printf ("Please enter hdl cholesterol \n");
scanf ("%d", a[i].hdl);
}
int x;
for(x=0; x<=3; x++)
{
cholesterol_level=(a[x].ldl/a[x].hdl);
}
}
This is what it's supposed to do.
You will define a patient structure for a patient checkup. The patient will have an id (letters and numbers), systolic blood pressure, diastolic blood pressure, ldl cholesterol, and hdl cholesterol. Check the input for the proper field types and sizes.
In main, you will declare an array of 4 patients. You will be using a for loop to fill up the array of patients. Again, check input format. The user will be prompted and will input each of the fields.
After a few new lines, you will print out the list of patients. At the top of the output, print a centered title Patient's Report, a blank line, and the column headings – Patient ID, Blood Pressure, and Cholesterol Ratio. Then with another for loop, print the patient id field, the blood pressure - systolic/diastolic (with the slash), and cholesterol ratio (ldl divided by hdl) with 2 decimal places. Make sure they print centered under the column headings by using field widths, precisions, alignments, etc.