Hey guys-
I'm having an issue with this program I wrote. It is supposed to have a user enter values and then output the maximum value of those values entered, using very basic C Programming. If only the sentinel value is entered, it will print out an error message. I have that working properly, but when I enter values, it outputs the maxmium, but when I enter the sentinel value (999), it outputs that as the maximum, which it shouldn't do. Any ideas? I'm probably just overlooking something very simple. I appreciate the help! Thanks!!
-----------------
Code:... while (temp != 999) { printf("Enter another value [enter 999 to stop]:\n"); scanf("%f",&temp); counter == counter++; if ( temp > max) { max = temp; } else if ( temp < max) { temp = temp; } } if ( counter != 1 ) { printf("The maximum is: %f\n", max); } else { printf("No valid entires:\n"); } }



LinkBack URL
About LinkBacks


