How to calculate average?

Can anyone tell me how to calculate average in a C++ program for e.g average of numbers?

I have used the following code:
Average=0
Average+=Marks_Eng+Marks_Hin+Marks_Math+Marks_Sci%4;

This does not give me correct output.
Last edited on
% (modulo) finds the remainder.
http://en.wikipedia.org/wiki/Modulo_operator

Use division instead.

EDIT: Deleted later reply as jdd beat me to it.
Last edited on
done that...does not work...
Also keep in mind the order of operations. Division (or modulo) happens before addition. You need to group the items being averaged.

Average = ( num1 + num2 + ... numn ) / n
thanks jdd...it worked:-)...i will keep this in mind...
thanks chungolongo!
Topic archived. No new replies allowed.