IvoSilva

[PROG1] Ficha 5 | Exercício 3

Nov 17th, 2011
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. float peso(float altura , char sexo)
  3. {
  4.     if (sexo == 'M') return (72.7 * altura - 58) ;
  5.     else if (sexo == 'F') return (62.1 * altura - 44.7) ;
  6. }
  7. int main ()
  8. {
  9.     float altura ;
  10.     char sexo ;
  11.     printf ("Insira a altura da pessoa: ") ;
  12.     scanf ("%f" , &altura) ;
  13.     printf ("Insira o género da pessoa(M/F): ") ;
  14.     scanf ("\n%c" , &sexo) ;
  15.     printf ("O peso ideal seria de %.2f quilos.\n" , peso(altura , sexo)) ;
  16.     return 0 ;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment