Can I suggest a number of changes?
Code:
#include <stdio.h>
int main() {
float temp;
int counter = 0;
float max;
printf("Enter a temperature [enter 999 to stop]:\n");
scanf("%f", &temp);
while (temp != 999) {
counter++;
if (temp > max) {
max = temp;
}
printf("Temperature = %f\n", temp);
printf("Counter = %d\n", counter);
printf("Maximum = %f\n", max);
printf("Enter a temperature [enter 999 to stop]:\n");
scanf("%f", &temp);
}
if (counter > 1) {
printf("The maximum temperature is: %f\n", max);
} else {
printf("No valid temperatures were entered\n");
}
return 0;
}
Edit: Formatting