0
How I compute average marks from array of objects ?
4 Answers
+ 4
Declare a double variable before the loop.
During loop sum all marks to this variable.
After divide the sum(variable) by 5 or by the array's length if you plan to add more elements.
+ 2
Thanks
+ 1
As a side note, it might be better to use a floating point type for the <student_marks> field. Use of int for average isn't really a good idea, because average is supposedly a percentage value : )
0
Muhammad Bilal You're welcome.