#include<stdio.h>
main()
{
int age, i=0;
while (i<=20)
{
printf("Please enter your age\n\n");
scanf("%d",&age);
if((age >= 60))
printf("warga emas\n");
else if((age <= 59) && (age >= 25))
printf("Dewasa\n");
else if((age <= 24) && (age >= 12))
printf("Remaja\n");
else
printf("kanak kanak riang\n");
i++;
}
}
without loop
#include<stdio.h>
main()
{
float weight, height, bmi_value;
char name[20];
printf("\nplease enter your name\n");
scanf("%s",&name);
printf("\nplease enter your weight\n");
scanf("%f",&weight);
printf("\nplease enter your height in meter\n");
scanf("%f",&height);
bmi_value = weight/(height*height);
printf("\nyour bmi value is = %.1f\n" ,bmi_value);
if((bmi_value >= 30.0))
printf("\nyour bmi status is obese\n");
else if((bmi_value <= 29.9) && (bmi_value >= 25.0))
printf("\nyour bmi status is overweight\n");
else if((bmi_value <= 24.9) && (bmi_value >= 18.5))
printf("\nyour bmi status is normal\n");
else
printf("\nyour bmi status is underweight\n");
}
No comments:
Post a Comment