852. Average of All Elements in an Array

Given an array nums of n integers, return Average of all Elements of given array.

Example 1:

Input : nums = [1, 2, 3, 4, 5]

Output : 3

Explanation :

(1+2+3+4+5) / 5 = 15 / 5 = 3

Example 2:

Input : nums = [5, 8, 11]

Output : 8

Explanation :

(5+8+11) / 3 = 24 / 3 = 8

Now Your Turn!

Pick the correct output for the given input

Input : nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 100
  • 1 <= nums[i] <= 100
0
class Solution {
public:
double averageOfArray(vector<int>& nums) {
// Your code goes here
}
};
Test Case

Input:

Nums