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

Please write the program in C LANGUAGE. Morover, implement the use of \"struct.\

ID: 3733960 • Letter: P

Question

Please write the program in C LANGUAGE. Morover, implement the use of "struct." Finally, please provide comments and documentation to aid in understanding of why you did what you did. Thank you so much!

Use the sample outputs as a guideline.

Description Create a C program that reads simulated patient health information from standard input, performs a bit of analysis on that data and outputs a summary of the information. You must write a software program to prompt the user for two different types of patient health information: patient vital information and patient activity information. The patient vital information consists of three pieces of information float temperature; unsigned int systolicPressure; unsigned int diastolicPressure; You should represent the patient vital information as a structure with these three members The patient activity information consists of two pieces of information: unsigned int stepCount; unsigned int sleepHours; You should represent the patient activity information as a structure with these two members To simulate the memory efficiency requirements of a health device, you should use an abstract data type to hold either patient vital information or patient activity information in a memory efficient manner. Operation When the program starts, ask the user if they wish to: 1Enter some patient vital information 2- Enter some patient activity information 3 - Print summary information on the patient information and exit the progranm If the user wishes to enter some patient vital information, you should prompt for the three pieces of information and store that information in an array for later processing

Explanation / Answer

#include <stdio.h>
struct patientVital //declaration of structure
{
    float temperature;       //var. declaration
    unsigned int systolicPressure, diastolicPressure;       //variable declaration
}pV[10];       //array of structure of size 10
struct patientActivity       //declaration of second structure
{
    unsigned int stepCount, sleepHours;       // variable declaration
}pA[10];       //array of structure of size 10

int b[10], a[50], count1=0, count2=0, i=0, n=0, k=0;       //global var. declaration
float maxT=0, minT =0, maxSP = 0, minSP=0, maxDP=0, minDP=0, TS=0, TSH=0;       //global var. declaration

//function defination
void patientVitalSet()
{
    printf("Enter the temperature:");
    scanf("%f", &pV[count1].temperature);
    printf("Enter the systolic pressure:");
    scanf("%d", &pV[count1].systolicPressure);
    printf("Enter the diastolic pressure:");
    scanf("%d", &pV[count1].diastolicPressure);
  
//used to store values in an array a
    while(n!=1)
    {
        a[i] = pV[count1].temperature;
        i++;
        a[i] = pV[count1].systolicPressure;
        i++;
        a[i] = pV[count1].diastolicPressure;
        i++;
        n=1;
    }
    n=0;
    count1++;       //no. of patient inc.
}

//function declaration
void patientActivitySet()
{
    printf("Enter the step count:");
    scanf("%d", &pA[count2].stepCount);
    printf("Enter the sleep hours:");
    scanf("%d", &pA[count2].sleepHours);

//used to store values in the same array a
    while(n!=1)
    {
        a[i] = pA[count2].stepCount;
        i++;
        a[i] = pA[count2].sleepHours;
        i++;
        n=1;
    }
    n=0;
    count2++;       //no. of patient inc.
}

//summary function defination
void summary()
{
    int l=0, j=0;
    minT = maxT;
    minSP = maxSP;
    minDP = maxDP;
//used to find maximum and minimum values
    for(l=0; l<=k; l++)
    {
        if(b[l]==1)
        {
           if(a[j]>=maxT)
            {
                maxT=a[j];
            }
            if(a[j]<=minT)
            {
                minT=a[j];
            }
          
            j++;
          
            if(a[j]>=maxSP)
            {
                maxSP=a[j];
            }
            if(a[j]<=minSP)
            {
                minSP=a[j];
            }
          
            j++;
          
            if(a[j]>=maxDP)
            {
                maxDP=a[j];
            }
            if(a[j]<=minDP)
            {
                minDP=a[j];
            }
            j++;
        }
      
        else if(b[l] == 0)
        {
            TS += a[j];
            j++;
            TSH += a[j];
            j++;
        }
    }

  
    printf("Number of patient vital information records: %d", count1);
    printf(" Maximum temperature: %f", maxT);
    printf(" Minimum temperature: %f", minT);
    printf(" Maximum systolic pressure: %f", maxSP);
    printf(" Minimum systolic pressure: %f", minSP);
    printf(" Maximum diastolic pressure: %f", maxDP);
    printf(" Minimum diastolic pressure: %f", minDP);
  
    printf(" Number of patient activity information records: %d", count2);
    printf(" Total step count: %f", TS);
    printf(" Total sleep hours: %f ", TSH);
}

int main()
{
   int ch;
    printf("Please enter the number for the desired action (1, 2, 3) :");
    printf(" 1 - Enter some patient vital information ");
    printf(" 2 - Enter some patient activity information ");
    printf(" 3 - Print summary information on the patient information and exit the program");
    scanf("%d", &ch);
    while(ch!=0)
    {
    switch(ch)
    {
        case 1:
                b[k] = 1;
                k++;
                patientVitalSet();
                break;
        case 2:
                b[k] = 0;
                k++;
                patientActivitySet();
                break;
        case 3:
                summary();
                break;
        default:
                printf("Please Enter 1, 2 or 3");
    }
    printf("Please enter the number for the desired action (1, 2, 3) :");
    printf(" 1 - Enter some patient vital information ");
    printf(" 2 - Enter some patient activity information ");
    printf(" 3 - Print summary information on the patient information and exit the program");
    scanf("%d", &ch);
    }
    return 0;
}