Итак, я создал простую программу, позволяющую пользователю вводить температуру и вычислять самую высокую, самую низкую и среднюю температуру. После того, как пользователь ввел дозорное значение, чтобы остановить цикл, дозорное значение каким-то образом также будет принято в качестве входных данных и испортит данные, вот мой код, пожалуйста, помогите мне взглянуть, если у вас есть время, большое спасибо
#include <stdio.h>
int main()
{
int temperature, highest = 0, lowest = 0, counter = 1, counter2 = 0, total = 0;
float average;
printf("Enter temperature (-999 to stop) > ");
scanf("%d", &temperature);
if (temperature == -999) {
printf("No temperature is captured.");
return 0;
}
else if (temperature > 40)
counter2++;
do {
printf("Enter temperature (-999 to stop) > ");
scanf("%d", &temperature);
if (temperature >= highest)
highest = temperature;
if (temperature <= lowest)
lowest = temperature;
if (temperature > 40)
counter2++;
total += temperature;
counter++;
} while (temperature != -999);
average = total / counter;
printf("Total days with temperature more than 40'C > %d\n", counter2);
printf("The lowest temperature > %d\n", lowest);
printf("The highest temperature > %d\n", highest);
printf("Average of temperature > %.2f\n", average);
}