why's is my csis.txt saving ?
#include <stdio.h>
FILE*fp;
void calculateBMI(void);
int main(void) {
fp = fopen("csis.txt", "w");
for (int i= 0; i<4; ++i){
calculateBMI();
}
fclose(fp);
return 0;
}
void calculateBMI(void){
double weight,height,bmi;
printf("Enetr your weight in pounds:\n\n");
fprintf(fp,"Enter your weight in pounds:\n\n");
scanf("%lf",&weight);
printf("Enter height in inches:\n\n");
fprintf(fp,"Enter height in inches:\n\n");
scanf("%lf",&height);
bmi=(703*weight)/(height*height);
if (bmi<18.5){
printf("You have a BMI of %.lf, and your weight status is underweight\n",bmi);
fprintf(fp,"You have a BMI of %.lf, and your weight status is underweight\n",bmi);
}else if (bmi>=18.5 && bmi<25){
printf("You have a BMI of %.lf, and your weight status is normal\n", bmi);
fprintf(fp,"You have a BMI of %.lf, and your weight status is normal\n", bmi);
} else if (bmi >= 25 && bmi < 30) {
printf("You have a BMI of %.lf, and your weight status is overweight\n", bmi);
fprintf(fp,"You have a BMI of %.lf, and your weight status is overweight\n", bmi);
}
else {
printf("You have a BMI of %.lf, and your weight status is overweight\n", bmi);
fprintf(fp,"You have a BMI of %.lf, and your weight status is overweight\n", bmi);
}
}
`Hey,
Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.
tHE CSIS.TXT IS SAVING EXACTLY WHAT IS displayed on command line as result
Your command line asks for input 4 times and then it displays the result as well as it saves that result in csis.txt
So, csis.txt file looks like below
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.