First,
* Lines 14-16 and 41-42 declare variables that you never use
* Line 66: You don't need the keyword 'struct' in declarations in C++.
studRec s[n];
is enough
* Pedantically, the 'n' on line 65 should be
constexpr
, because the size of array (on line 66) must be a compile-time constant
You have only two student records, so their average would be trivial (a+b)/2.0.
Overall, average is sum of values divided by their count.
However, sum of integers divided by '2' -- an integer -- is also an integer.
Integer divided by 2.0 -- a double -- produces a double result.
Sum of values in array can be computed with
std::accumulate
http://www.cplusplus.com/reference/numeric/accumulate/
but you could as well use a loop.
One does not compute result "
with 2 decimal places". Calculate with the precision of your data type (double).
One does
show 2 decimal places:
http://www.cplusplus.com/reference/iomanip/setprecision/