Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- float LerPositivoInteiro(){
- int num;
- do{
- scanf("%d", &num);
- if(num < 0){
- printf("Numero negativo. Informe novamente!");
- }
- }while(num <0);
- return num;
- }
- float LerPositivoReal(){
- float num;
- do{
- scanf("%f", &num);
- if(num < 0){
- printf("Numero negativo. Informe novamente!");
- }
- }while(num <0);
- return num;
- }
- float imc(float peso, float altura){
- float IMC;
- IMC = peso / (altura*altura);
- return IMC;
- }
- void imprimeimc(int idade, float imc){
- if(idade <= 30){
- if(imc<17){
- printf("Muito magra\n");
- }else
- if(imc<22){
- printf("Magra\n");
- }else
- if(imc<27){
- printf("Normal\n");
- }else
- if(imc<33){
- printf("Acima\n");
- }else{
- printf("Obesa\n");
- }
- }else{
- if(imc<18){
- printf("\nMuito magra");
- }else
- if(imc<24){
- printf("\nMagra\n");
- }else
- if(imc<27){
- printf("\nNormal");
- }else
- if(imc<31){
- printf("\nAcima");
- }else{
- printf("\nObesa\n");
- }
- }
- }
- int main()
- {
- int idade;
- float peso, altura;
- float valorimc;
- int x;
- printf("Insira a sua idade:");
- idade = LerPositivoInteiro();
- printf("Insira o valor do peso:");
- peso = LerPositivoReal();
- printf("Insira o valor da altura:");
- altura = LerPositivoReal();
- valorimc = imc(peso, altura);
- printf("O valor do IMC: %f", valorimc);
- imprimeimc(idade, valorimc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement