このラボでは、メイン関数を編集することはできません。すべての関数はmain以下の関数で実行する必要があります。私はここで私の問題を見つけることができないようです。私はそれがcalculateBMI関数の呼び出しと関係があると思います。BMI計算機ラボで問題が見つかりません
#include <stdio.h>
FILE *fp;
//For loop, which allows up to 4 entries.
int main(void) {
int i;
fp = fopen("csis.txt", "w");
for (i = 1; i <= 4; ++i) {
calculateBMI();
}
fclose(fp);
return 0;
}
//Function that calculates the BMI of the Input.
double calculateBMI(int weightInPounds, int heightInInches) {
double BMI;
BMI = weightInPounds * 703/heightInInches * heightInInches;
//If BMi is less then 18.5 print this.
if (BMI < 18.5) {
printf("Your BMI is %d, you are underweight.", BMI);
fprintf(fp, "Your BMI is %d, you are underweight.", BMI);
}
//if BMI is between 18.5 and less then 25 print this.
else if (BMI > 18.5 & BMI < 25) {
printf("Your BMI is %d, you are Normal.", BMI);
fprintf(fp, "Your BMI is %d, you are Normal.", BMI);
}
//if BMI is greater then 25 and less then 30 print this.
else if (BMI > 25 & BMI < 30) {
printf("Your BMI is %d, you are Overweight.", BMI);
fprintf(fp, "Your BMI is %d, you are Overweight.", BMI);
}
//if BMI is greater then 30 print this.
else (BMI > 30) {
printf("Your BMI is %d, you are Obese.", BMI);
fprintf(fp, "Your BMI is %d, you are Obese.", BMI);
}
//Asks user for input weight in pounds.
printf("What is your weight in pounds?");
fprintf(fp, "What is your weight in pounds?");
scanf("%d\n", weightInPounds);
fscanf(fp, "%d\n", weightInPounds);
// Asks user for input height in inches.
printf("What is your height in inches?");
fprintf("What is your height in inches?");
scanf("%d\n", heightInInches);
fscanf(fp, "%d\n", heightInInches);
getchar(0);
return (0);
}
をあなたの「問題」と見つけることができません「問題を?」コンパイラからは非常に多くの警告とエラーがありますので、コンパイラから通知されたとおり、それらを1つずつ記述する必要があります。すべてのコンパイラの警告を有効にしてください。 –
申し訳ありませんが、急いでおり、このフォーラムは初めてです。 – Chris