Here is the code that i came up with to input some numbers and then try to average them. The only problem i really have right now is how to count the loops so i can divide it as an average.
Code:
#include <stdio.h>
main()
{
float n, answer, average = 0, loop = 0, sum = 0.0;
printf("This program averages grades.\n");
printf("Please enter the grades: \n\n\n");
scanf("%f", &n);
while (n >= 0)
{
sum += n;
scanf("%f", &n);
}
printf("%.2f \n", n);
printf("the sum is: %.2f \n", sum);
average = sum / n;
printf("average is: %.2f \n", average);
return 0;
}