I'm trying to make a program that computes a grade average, tells how many students are passing and how many are above average. I've got the above passing grades and the grade average figured. I need help figuring out how to show how many grades are above average. Heres my source code, any input is appreciated.
sum = 0; % sum of grades
counter = 0;
aboveaverage = 0;
n = input('input number of students:');%how many students?
for i = 1:n
grade(i) = input('input grade: '); % students grades
sum = sum + grade(i);
if(grade(i) >= 6)
counter = counter + 1;
avg = sum/n;% grade average
if (grade(i) >= (sum/n))
aboveaverage=aboveaverage+1; %calculate number of grades above avg
fprintf(1,'Avg = %g With %g passing grades
fprintf(1,'Students above average: = %g