Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
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