Header Ads

Calculating average marks obtained by a student

How to calculate average marks obtained by a student in given no. of subjects using one-dimensional matrix in C

************************************Program*************************************


#include<stdio.h>
#include<conio.h>
main()
{
    int n,i;
    int m[10];
    float avg=0;
    printf("Enter the number of subjects : ");
    scanf("%d",&n);
    printf("\n\n");
    for(i=1;i<=n;i++)
    {
        printf("Enter the mark of subject%d : ",i);
        scanf("%d",&m[i]);
        avg=m[i]+avg;
    }
    avg=avg/n;
    printf("\n\n");
    printf("Average marks obtained by student in %d subjects is : %.3f",n,avg);
    getch();

}


************************************Output***************************************


Screen shot for above program



No comments