10 ตุลาคม 2551

โปรแกรม สำหรับคำนวณน้ำหนักมาตรฐาน

#include
#include
void main()
{
float weight,height,standard;
char gender,name[30];
    clrscr();
    printf("Input Name     : ");scanf("%s",&name);
    printf("Input Height   : ");scanf("%f",&height);
    printf("Input Weight   : ");scanf("%f",&weight);
    printf("Input Gender   : ");scanf("%s",&gender);
    printf("\n");
    printf("\n");
    printf("\n");
    if (gender =='M' || gender == 'm') standard = height - 100;
       else  standard = height - 110;
    if ( standard == weight) printf("%s Weight Is Standard",name);
       else if (standard > weight) printf("%s Weight Is Under Standard %.2f Kg",name,standard-weight);
       else  printf("%s Weight Is Over Standard %.2f Kg",name,weight-standard);
    getch();
}