constchar *name = "TopicD.cpp";
std::ifstream input_file( name );
if ( !input_file )
std::cerr << "Error: file " << name << " can not be opened" << std::endl;
std::exit( 1 );
int sum = 0;
int count = 0;
while ( input_file >> number ) sum += number, ++count;
if ( count != 0 )
std::cout << "There are " << count << " numbers in the file" << std::endl;
std::cout << "The sum of the numbers is " << sum << std::endl;
std::cout << "The average of the numbers is " << sum / count << std::endl;
For median and mode I would agree with you, but the average could still have fractional data even if all the inputs are integers.
I do not argue because I do not see the subject of the discussion. I only see that you have some problems with integers. It is your problems not main. You personally can use a floating type but I prefered to use the integer type for the average of a sequence of integers.