#include <iostream>
using namespace std;
int main() {
    int n;
    std::cin >> n;

    if (n < 1) {
        return 0;
    }
    int *buffer=new int[n];
    int sum =0;
    for(int i=0;i<n;i++){
        cin>> buffer[i];
        sum+=buffer[i];
    }
    float average = sum/n;
    cout << static_cast<float>(average);
    delete[] buffer;
        // Write your dynamic buffer allocation code here

    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

5 10 20 30 40 50

Expected Output

30