//main function main() { //variable declarations int score, sum = 0, count = 0; double average; printf("Enter a test score (-1 to quit):"); scanf("%i", &score); while (score != -1) { count = count + 1; sum = sum + score; printf("Enter a test score (-1 to quit):"); scanf("%i", &score); } average = (double) sum / count; printf("\nThe sum of the scores is: %i\n", sum); printf("You entered %i scores. \n", count); printf("The average score is: %.2lf\n", average); system("Pause"); } //end main
I need help to write a code for the computer to determine the lowest and highest test score !? please help
If this is an addition to the code above, just declare a variable lowest to a high value, like a million, and a variable highest set to zero and compare and (maybe) replace as you go through the scores.
Join our real-time social learning platform and learn together with your friends!