I have a text file containing 200 numbers. I want to calculate the average value of those numbers (because it takes way too long to do it by hand). I have no idea how to accomplish this, because I have never done such a thing. Thanks in advance.
Edit: I tried searching google but couldnt find something usefull.
A simple C++ program would implement the following steps:
doublevaluestd::vector, read about itstd::vectorthere are again a lot of possibilities; try to find 3 different solutions to learn good C++ style. (google for STL algorithms)coutHave a look at these steps and ask concrete questions if you encounter problems.
However, you don’t need a C++ program to do this. A spreadsheet program is the perfect tool for this.
If you don’t like GUI programs for such tasks, SQLite is a perfect tool, too. Open the SQLite shell and type (assuming
data.txtis your file with a decimal number on each line):