Medical Application : Medical clinics measure total cholesterol, using the formu
ID: 3679316 • Letter: M
Question
Medical Application : Medical clinics measure total cholesterol, using the formula = HDL + LDL + ( TGL / 5 ) where HDL is good cholesterol, LDL is bad cholesterol and TGL is triglycerides. Note: Only one fifth of the TGL is added to the total cholesterol. Jack's HDL starting from 1995 until 2014 is : 29 32 34 21 28 34 32 35 30 31 28 27 38 40 42 47 50 52 39 41 His LDL from 1995 is 170 174 180 163 168 179 154 181 164 153 145 159 169 140 134 84 78 81 83 75 His TGL is 120 110 95 100 105 85 99 70 74 84 101 99 83 70 65 60 85 82 72 55 Stored them in individual array as HDL, LDL, TGL and each array contain 20 cells. Now we are interested in . Program 1: Compute the Maximum HDL and the year : [10 points ] Because HDL is preferred to be high for everyone, can you write a program to print the MAX HDL and the year in which it is maximum in Jack's data. If two years have the same HDL values, print the recent one. Program 2 : Minimum LDL and the year : [10 points] Because LDL should be low for everyone, can you write a program to print the minimum LDL and the year in which it is minimum in Jack's data. If two years have the same LDL values, print the recent one. Program 3 : Print the total cholesterol for each year and print the doctors comments as follows. [ 20 points ] If total value is less than 200, Print a message as : Jack : Your Lipid levels are good. If total value is between 201 and 239, Print a message as : Jack, your lipid levels are Borderline If total value is more than 240, Print a message as : Jack, you are at a very High Risk of dying. For instance, your output should be 1995 212 Jack, your lipid levels are Borderline 1996 198 Jack : Your Lipid levels are good. ... until 2014 in C language
Explanation / Answer
Please find the required code below :
#include <stdio.h>
#include <string.h>
void maxHDL(int HDL[]){
int max = HDL[0],idx=0;
for(int i=1; i<20; i++){
if(HDL[i]>=max){
max = HDL[i];
idx = i;
}
}
printf("Max HDL is %d in year %d",max,1995+idx);
}
void minLDL(int LDL[]){
int min = LDL[0],idx=0;
for(int i=1; i<20; i++){
if(LDL[i] <= min){
min = LDL[i];
idx = i;
}
}
printf(" Min LDL is %d in year %d",min,1995+idx);
}
int main()
{
int HDL[] = {29,32,34,21,28,34,32,35,30,31,28,27,38,40,42,47,50,52,39,41};
int LDL[] = {170,174,180,163,168,179,154,181,164,153,145,159,169,140,134,84,78,81,83,75};
int TGL[] = {120,110,95,100,105,85,99,70,74,84,101,99,83,70,65,60,85,82,72,55};
maxHDL(HDL);
minLDL(LDL);
for(int i=0; i<20; i++){
double tc = HDL[i] + LDL[i] + (TGL[i]/5);
char msg[50];
if(tc < 200)
strcpy(msg,"Jack : Your Lipid levels are good.");
else if(tc > 201 && tc < 239)
strcpy(msg,"Jack, your lipid levels are Borderline");
else
strcpy(msg,"Jack, you are at a very High Risk of dying.");
printf(" %d %f %s",1995+i,tc,msg);
}
return 0;
}