Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- typedef struct people {
- float mass ;
- float height ;
- } p;
- struct people startStruct(float m, float h) {
- struct people aux ;
- int i ;
- aux.mass = m ;
- aux.height = h ;
- return aux ;
- }
- float imc(float mass, float height) {
- return mass / pow(height, 2) ;
- }
- float min(float mass, float imc, float result) {
- return ((result * mass) / imc) - mass ;
- }
- float max(float mass, float imc, float result) {
- return (((result * mass) / imc) - mass) * -1 ;
- }
- void show(struct people aux) {
- float ind = imc(aux.mass, aux.height);
- printf("you are with IMC of: %.2f", ind);
- if(ind < 16) {
- printf(" - [Magreza grave]");
- } else if(ind >= 16 && ind < 17) {
- printf(" - [Magreza moderada]");
- } else if(ind >= 17 && ind < 18.5) {
- printf(" - [Magreza leve]");
- } else if(ind >= 18.5 && ind < 25) {
- printf(" - [Saudavel]");
- } else if(ind >= 25 && ind < 30) {
- printf(" - [Sobrepeso]");
- } else if(ind >= 30 && ind < 35) {
- printf(" - [Obesidade grau 1]");
- } else if(ind >= 35 && ind < 40) {
- printf(" - [Obesidade grau 2 Severa]");
- } else {
- printf(" - [Obesidade grau 3 Morbida]");
- }
- if(ind - 18.5 > 0 && ind > 6.5) {
- printf("\nVoce deve perder no minimo %.2fkg para se tornar saudavel\n\n", max(aux.mass, ind, 24.9));
- } else if(ind - 18.5 < 0) {
- printf("\nVoce deve ganhar no minimo %.2fkg para se tornar saudavel\n\n", min(aux.mass, ind, 18.5));
- }
- }
- int main(int argc, char* argv[]) {
- struct people _bruno ;
- struct people _olivia ;
- // Bruno Informations
- _bruno = startStruct(122, 1.84);
- // Olivia Informations
- _olivia = startStruct(45, 1.76);
- // function call
- printf("Bruno, ");
- show(_bruno);
- printf("Olivia, ");
- show(_olivia);
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement