Advertisement
Raul_julian

aeds.c

Mar 26th, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4.  
  5. typedef struct people {
  6.  
  7.     float mass ;
  8.     float height ;
  9. } p;
  10.  
  11. struct people startStruct(float m, float h) {
  12.    
  13.     struct people aux ;
  14.     int i ;
  15.  
  16.     aux.mass = m ;
  17.     aux.height = h ;
  18.  
  19.     return aux ;
  20. }
  21.  
  22. float imc(float mass, float height) {
  23.     return mass / pow(height, 2) ;
  24. }
  25.  
  26. float min(float mass, float imc, float result) {
  27.     return ((result * mass) / imc) - mass ;
  28. }
  29.  
  30. float max(float mass, float imc, float result) {
  31.     return (((result * mass) / imc) - mass) * -1 ;
  32. }
  33.  
  34. void show(struct people aux) {
  35.  
  36.     float ind = imc(aux.mass, aux.height);
  37.  
  38.     printf("you are with IMC of: %.2f", ind);
  39.  
  40.     if(ind < 16) {
  41.         printf(" - [Magreza grave]");
  42.     } else if(ind >= 16 && ind < 17) {
  43.         printf(" - [Magreza moderada]");
  44.     } else if(ind >= 17 && ind < 18.5) {
  45.         printf(" - [Magreza leve]");
  46.     } else if(ind >= 18.5 && ind < 25) {
  47.         printf(" - [Saudavel]");
  48.     } else if(ind >= 25 && ind < 30) {
  49.         printf(" - [Sobrepeso]");
  50.     } else if(ind >= 30 && ind < 35) {
  51.         printf(" - [Obesidade grau 1]");
  52.     } else if(ind >= 35 && ind < 40) {
  53.         printf(" - [Obesidade grau 2 Severa]");
  54.     } else {
  55.         printf(" - [Obesidade grau 3 Morbida]");
  56.     }
  57.  
  58.     if(ind - 18.5 > 0 && ind > 6.5) {
  59.         printf("\nVoce deve perder no minimo %.2fkg para se tornar saudavel\n\n", max(aux.mass, ind, 24.9));
  60.     } else if(ind - 18.5 < 0) {
  61.         printf("\nVoce deve ganhar no minimo %.2fkg para se tornar saudavel\n\n", min(aux.mass, ind, 18.5));
  62.     }
  63. }
  64.  
  65. int main(int argc, char* argv[]) {
  66.  
  67.     struct people _bruno ;
  68.     struct people _olivia ;
  69.    
  70.     // Bruno Informations
  71.     _bruno = startStruct(122, 1.84);
  72.  
  73.     // Olivia Informations
  74.     _olivia = startStruct(45, 1.76);  
  75.  
  76.     // function call
  77.     printf("Bruno, ");
  78.     show(_bruno);
  79.     printf("Olivia, ");
  80.     show(_olivia);
  81.  
  82.     return 0 ;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement