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

class Averager {
public:
    vector<int> numbers;

    void add(int num) {
        numbers.push_back(num);
    }

    double get_avg() {
        int sum = 0;
        for (int n : numbers) sum += n;
        return (double)sum / numbers.size();
    }
};

int main() {
    Averager avg;
    avg.add(10);
    avg.add(20);
    avg.add(30);
    cout << avg.get_avg() << endl;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: