0
#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;
}

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kneel
0

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.

0

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");
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.