C program to find average of or marks scored by a student.

 Simple program to find average of marks of student :

#include<stdio.h>
float findAverage(int marks[]);

int main()
{
    float avg;
    int marks[]={99,90,96,93,95};
    avg= findAverage(marks);
    printf("Average marks = %.1f",avg);
    return 0;
}
float findAverage(int marks[])
{
    int i,sum=0;
    float avg;

    for(i=0;i<=4;i++)
    {
        sum += marks[i];
    }

    avg =(sum/5);
    return avg;
}

Output :

Average marks = 94.0
Process returned 0 (0x0)   execution time : 0.094 s
Press any key to continue.

Post a Comment

2 Comments

  1. Write a program to declare int x, y float k, m and f char chk[10]. Initialize some values

    ReplyDelete

Thanks,To visit this blog.