I'm very new at this and am stuck on a loop problem.
I'm trying to make an averageing loop but the loop won't ask for the next input. This is what I have:
#include <stdio.h>
void main (void)
{
float sum = 0, score, average;
int number;
printf("Number of Floats to average? "
scanf("%i", &number);
printf("\n"
for (int x = 1; x <= number; x++)
{
sum = sum + score;
printf("Score %i= ", x);
scanf("%.2f", &score);
printf("\n"
}
printf("\nYour total is %.2f\n", sum);
average = sum / number;
printf("\nThe Average of the %i Scores = %.2f\n\n", number, average);
}
The output will number the lines but places -107374176.00 in as the score no matter what I do.
Help!!!
Thanks
Yarbz2
I'm trying to make an averageing loop but the loop won't ask for the next input. This is what I have:
#include <stdio.h>
void main (void)
{
float sum = 0, score, average;
int number;
printf("Number of Floats to average? "
scanf("%i", &number);
printf("\n"
for (int x = 1; x <= number; x++)
{
sum = sum + score;
printf("Score %i= ", x);
scanf("%.2f", &score);
printf("\n"
}
printf("\nYour total is %.2f\n", sum);
average = sum / number;
printf("\nThe Average of the %i Scores = %.2f\n\n", number, average);
}
The output will number the lines but places -107374176.00 in as the score no matter what I do.
Help!!!
Thanks
Yarbz2