Menu
Coddy logo textTech

1. Calculate Average

Lesson 2 of 31 in Coddy's 30 Days of Logic Building in C++ course.

challenge icon

Challenge

Easy

Write a function to calculate the average of an array of numbers.

  • Input: [3, 7, 11, 5]
  • Output: 6.5

Try it yourself

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

float calculateAverage(vector<int> nums) {
    // Write code here
}

All lessons in 30 Days of Logic Building in C++