finding a minimum in a file of integers

I'm working on an assignment for school and I'm a little stuck on something. Part of my assignment entails finding the minimum of a set of numbers in a file that is opened by the program and then have it subtract that minimum from the total of the integers. For example, if the file contains the integers 87, 93, and 76, the program should be able to find that the minimum is 76 and subtract that from the total of 87, 93, and 76 so that it seems like only 87 and 93 were added together.

I've looked through my notes and my book and found nothing. I've also found an archived forum on this site about finding a minimum in a set of numbers that are input by a user that I thought might be helpful, but I'm not sure if it is. It talked about the <climits> library and I'm pretty sure that's not what I need.
What ever it is you found is probably what you are looking for. If I were to write this program, I will start with something like:

1
2
3
4
5
6
7
8
9
#include <limts>
...

int main() {
    ...
    int min = std::numeric_limits<int>::max();
    int sum = 0;
    ...
}
Last edited on
This is my fault, but I forgot to add that I would appreciate it if commenters wrote their examples as though "using namespace std;" was included. It took me a while to figure out that was why the programs looked a little weird to me, but I still don't know how to read them in order to understand what it is that I need.

Could you please rewrite your program in that manner Smac89?
Topic archived. No new replies allowed.