Question
#include int main() { FILE *fp; int temp, count = 0, sum = 0; int low, high; int days = 10; // total number of
#include
int main() {
FILE *fp;
int temp, count = 0, sum = 0;
int low, high;
int days = 10; // total number of days in the file
// open the file in read only mode 'r'
fp = fopen("Temperatures.txt", "r");
// get temperature range from user
scanf("%d %d", &low, &high);
// iterate through the file and count and add the number of days that fall within the range
while (fscanf(fp, " %d", &temp) == 1) {
if (temp >= low && temp <= high) {
count++;
sum += temp;
}
}
// close the file
fclose(fp);
// print the result
if (count > 0) {
printf("%d days had a temperature between %d and %d ", count, low, high);
printf("The mean temperature between %d and %d is %.1f ", low, high, (float) sum / count);
} else {
printf("0 days had a temperature between %d and %d ", low, high);
printf("The mean value was not calculated, since there are zero days in the range ");
}
return 0;
}
Answer this question only: How do I fix it from saying 65.0 to 65.6 and 59.0 to 59.5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started