I compile and run...I enter test scores and the program keeps asking me to enter....it won;t stop...help.
it is the first while loop. i need it to end when the user hits Enter with no test score.
Purpose: Write a program that will find the lowest, highest, and average score for a set of test scores.
*********************************************************************/
#include
#include
#include
#include
main()
{
float score;
float average;
float x;
float max = 0;
float min = 1000; /*just in case there is extra credit*/
float total = 0;
float sum;
int i = 0;
char ac[BUFSIZ+1];
{
printf ("***********************************\n");
printf ("*****Test Score Statisics *****\n");
printf ("***********************************\n");
{
while ( score >= 0 ) {
printf("Please Enter test Score %d: ", i+1);
score = atoi(gets(ac));
if( score > max ) { /* Find Max Score*/
max = score;
}else{
if (score < min) { /* Find Min Score*/
min = score;
}
}
sum = score + sum; /* Find Sum Score*/
}
average = sum / i; /* Find Average Score*/
printf( "\n\nThe average score is %.1f\n", average);
printf( "%d Test Scores\n", i );
printf( "Maximun Test Score = %.1f\n", max);
printf( "Minimum Test Score = %.1f\n", min);
}
system("PAUSE");
return;
}}
2007-02-26
19:41:23
·
4 answers
·
asked by
importchef
2
in
Computers & Internet
➔ Programming & Design