Search⌘ K

Challenge: Calculate the Average Marks of a Class

Explore how to calculate the average marks of a class by working with arrays in C++. This lesson helps you understand array traversal, summation, and basic arithmetic operations to return the average value correctly. Build your problem-solving skills by implementing the average function and testing it with sample inputs.

Problem statement

Your task is to write a function average. Your function signature should be:

The input array marks[ ] will contain the marks of all the students in the class. Your task is to calculate the average marks of the class and return it in the output. It is assumed that the value of size will be greater than zero.

The basic formula for calculating the average of the values is given below:

Average=Sum of all val ...