Search
 
SCRIPT & CODE EXAMPLE
 

C

bp result system

#include <stdio.h>
#include <stdlib.h>

int getuserinput();
int calcaverage();
int clasifycondition();
int gethighest();

float bp[3][5];
char stdname[5][10];
float finalavg[5];
char condclass[5][20];
float highestavg;
char namecpy[5][10];

int main()
{
    getuserinput();
    calcaverage();
    clasifycondition();
    gethighest();


	


    printf("
Name        Mon        Tues         Wed        Avg        Condition");


    printf("
%s     %.2f     %.2f     %.2f     %.2f     %s",namecpy[0],bp[0][0],bp[0][1],bp[0][2],finalavg[0],condclass[0]);
    printf("
%s     %.2f     %.2f     %.2f     %.2f     %s",namecpy[1],bp[1][0],bp[1][1],bp[1][2],finalavg[1],condclass[1]);
    printf("
%s     %.2f     %.2f     %.2f     %.2f     %s",namecpy[2],bp[2][0],bp[2][1],bp[2][2],finalavg[2],condclass[2]);
    printf("
%s     %.2f     %.2f     %.2f     %.2f     %s",namecpy[3],bp[3][0],bp[3][1],bp[3][2],finalavg[3],condclass[3]);
    printf("
%s     %.2f     %.2f     %.2f     %.2f     %s",namecpy[4],bp[4][0],bp[4][1],bp[4][2],finalavg[4],condclass[4]);


    printf("
Highest Avg: %.2fmm HG

",highestavg);




    return 0;
}

int getuserinput()
{
    int daycounter=1,stdcounter=1;

     printf("========================================================================
");
	printf("======PUSAT KESIHATAN UNIVERSITI (PKU) UNIVERSITI MALAYSIA PAHANG=======
");
	printf("========================================================================
");

     
     for(int stdnum=0;stdnum<5;stdnum++)
        {
         printf("
Enter student name %d: ",stdcounter);
         scanf("%s",&stdname[stdnum]);
         stdcounter=stdcounter+1;
         strcpy(namecpy[stdnum],stdname[stdnum]);
             for (int x=0;x<3;x++)
               {
                printf("BP reading for day %d: ",daycounter);
                scanf("%f",&bp[stdnum][x]);
                daycounter=daycounter+1;
               }
             daycounter=1;
         }
    return bp;
}

int calcaverage()
{
    float avg;
    float sum;

     for(int x=0;x<5;x++)
     {
         avg=0;
         sum=0;

         for(int y=0;y<3;y++)
         {
            sum=sum+bp[x][y];

         }
         avg=sum/3;
         finalavg[x]=avg;
         //printf("
The %d average is%.2f",x,finalavg[x]);
     }

}
int clasifycondition()
{
  char class1[]="Pre-hypertension";
  char class2[]="Hypertension Stage 1";
  char class3[]="Hypertension Stage 2";
  char class4[]="Hypertensive Crisis";



    for(int x=0;x<5;x++)
    {
        if(finalavg[x]<120)
        {
            strcpy(condclass[x],"Normal");
        }

        else if(finalavg[x]>=120&&finalavg[x]<=139.99)
        {
            strcpy(condclass[x],class1);
        }

        else if(finalavg[x]>=140&&finalavg[x]<=159.99)
        {
            strcpy(condclass[x],class2);
        }

        else if(finalavg[x]>=160&&finalavg[x]<=179.99)
        {
            strcpy(condclass[x],class3);
        }

        else if(finalavg[x]>=180)
        {
            strcpy(condclass[x],class4);
        }

    }

}

int gethighest()
{
    for(int x=0;x<4;x++)
    {
        if(finalavg[x]>finalavg[x+1])
        {
            highestavg=finalavg[x];
        }
        else
        {
            highestavg=finalavg[x+1];
        }
    }

}



Comment

PREVIOUS NEXT
Code Example
C :: c read file from command line 
C :: short print variable in c 
C :: insse suprafata arabila pe ani 
C :: linux_reboot_magic2 
C :: C Accessing Union Members 
C :: git add -u flag 
C :: promt user input C 
C :: how to print chicken in c 
C :: what happens if i acess a freed variable in c 
C :: how to do Employing defensive code in the UI to ensure that the current frame is the most top level window 
C :: Minimum Distance between words[AMAZON] 
C :: install lib juicyPixel in haskell 
C :: scranton inhabitants 
C :: konami code hdl 
C :: can we update values of a map via traversing 
C :: arma 3 key pressed 
C :: Uri/Beecrowd Problem no - 1184 solution in C 
C :: float para numeros aleatorios em c 
C :: redis endpoint 
C :: clarity ppm jasper domain commands 
C :: sscanf and sprintf in c 
C :: c Modulo 10^9+7 (1000000007) 
C :: C programming statician 
C :: QDrag and Drop 
C :: C++ initalize int16_t value 
C :: download file by command line windows 
C :: babel customelement plugins 
Dart :: flutter transparent appbar 
Dart :: flutter border around textbutton 
Dart :: raised button deprecated flutter 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =