Try also (just to have a glimpse of modern
C++
,
Richard implementation, with just one traversal, is more efficient)
#include <iostream>
#include <algorithm>
#include <array>
#include <numeric>
using namespace std;
int main()
{
array<int,18> a{ 16,24,55,25,41,63,90,62,42,28,99,86,13,83,33,91,58,16 };
const auto beg = a.begin();
const auto end = a.end();
auto min = *min_element(beg, end);
auto max = *max_element(beg, end);
auto ge50 = count_if(beg, end, [](int x) { return x>= 50;});
auto sum = accumulate(beg, end, 0);
cout << "min " << min << ", max " << max << ", ge50 " << ge50 << ", sum " << sum << endl;
}