Write a program to find average marks of 4 different subjects obtained by 10 student in a test .
Use two dimensional array to store marks of student for each subject.
source file name: arr2davg.C
#include<stdio.h>
int main()
{
int i,j,sum=0,avg;
int stud[10][5]={
{501,15,15,15,15},{502,16,16,16,16},{503,15,16,17,20},
{504,17,18,19,20},{505,11,12,13,14},{506,12,14,16,18},
{507,17,15,19,14},{508,11,14,17,19},{509,12,16,14,18},
{510,13,14,15,16}};
//clrscr();
printf("\n Student Roll no and Average marks list: ");
for(i=0;i<10;i++)
{
sum=0;
for(j=1;j<5;j++)
{
sum=sum+stud[i][j];
}
avg=sum/4;
printf("\n %d %d ",stud[i][0],avg);
}
//getch();
return 0;
}
output:
0 Comments
Post a Comment