#include <iostream>
#include <list>
#include <numeric>
#include <algorithm>
using namespace std;
int main()
{
// create linked list of integers
list<int> the_list;
// input as requested
cout << " Enter length of the list " << endl;
size_t len;
cin >> len;
for(size_t i=0; i<len; ++i)
{
cout << " Enter value number " << i+1 << endl;
int tmp;
cin >> tmp;
the_list.push_back(tmp);
}
// output
double sum = accumulate(the_list.begin(), the_list.end(), 0.0);
cout << " Arithmetic Mean is " << sum/the_list.size() << endl;
cout << " Maximum value is " << *max_element(the_list.begin(), the_list.end()) << endl;
cout << " Minimum value is " << *min_element(the_list.begin(), the_list.end()) << endl;
}

Recommended Answers

All 4 Replies

what's wrong with it, or are we supposed to guess?

what's wrong with it to start with is the lack of code tags and formatting. Everything else is irrelevant as that means the code won't get read.

Hmm, it worked fine for me. Are you running from a command window or standalone? I added a pause at the end so that the standalone console app would not disappear after displaying the output.

system("pause");

Thx @tonymuilenburg
my code is worked now
i add the command u've given.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.