Array Program To Find Max, Avg, Compare Marks

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

// Find max score, average score & number of students score greater

than average score

#include <stdio.h>

int main() {

float score[20],maximumscore, averagescore,totalscore;

int i,n,no_of_students=0;

printf("\n Enter a number of students in class:");

scanf("%d",&n);

printf("\n enter %d scores \n \n",n);

for(i=0;i<n;i++)

scanf("%f",&score[i]);

totalscore =0;

for(i=0;i<n;i++){

totalscore+= score[i];

averagescore=totalscore/n;

maximumscore=score[i];

for(i=1;i<n;i++){

if(score[i]>maximumscore)
maximumscore=score[i];

for(i=1;i<n;i++){

if(score[i]>averagescore)

no_of_students++;

printf("\n maximum score of class =%.2f",maximumscore);

printf("\n average score of class =%.2f",averagescore);

printf("\n no. of students with score> of %.2f=%d\


n",averagescore,no_of_students);

return 0;

You might also like