Read them from a file with an ifstream ( http://www.cplusplus.com/doc/tutorial/files/ ) and store them into a std::vector. Then set the smallest and largest variables to the first element in the vector and loop through the remaining elements comparing them to those two variables and reassigning when they're less than smallest and greater than largest.